Question

Write a function in MATLAB called WORKDONE to calculate the area under the curve of a...

Write a function in MATLAB called WORKDONE to calculate the area under the curve of a PV diagram for a thermodynamic process, based on a single input, κ, the specific heat ratio. The values for P and V are defined below. The output of the function should be a single number equal to the area under the curve, found using the trapz command. Include these parameters in your function: V=0.001:0.001:0.02

P = 380/V^k

Homework Answers

Answer #1

Following is the code in WORKDONE.m :

function res = WORKDONE(k)
    
    %
    % Write the given definitions.
    %
    V = 0.001 : 0.001 : 0.02;
    
    %
    % While writing P, we must use dot-notations so that P is also a
    % vector.
    %
    P = 380 ./ (V .^ k);
    
    %
    % The work done is the area of P-V graph with the V-axis.
    % Thus, while using Matlab's trapz() method, we pass P as a vector.
    %
    res = trapz(P);
    
end

Following are some sample runs :

>> 
>> WORKDONE(1)

ans =

   1.1676e+06

>> WORKDONE(0.1)

ans =

   1.1651e+04

>> WORKDONE(12.3)

ans =

   1.5098e+39

>> 
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
2. 2052 Write a function in MATLAB called HTBALL to calculate the height of a ball...
2. 2052 Write a function in MATLAB called HTBALL to calculate the height of a ball based on a single input, the elapsed time. The elapsed time will be a single variable in the range of 0 to 6. Predict the value by fitting a 2nd order polynominal to the data points shown below using the polyfit command. Use the command polyval to determine the height of the ball at the inputted time. timevals=[0,.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6]; height=[0,46,84,114,136,150,156,154,144,126,100,66,24]; Copy and paste the data...
Write a MATLAB function that is called sphereva which can do the following: a- Receive one...
Write a MATLAB function that is called sphereva which can do the following: a- Receive one input argument, which represent the radius of a sphere. The input argument can either be a scaler, vector or matrix variable. b- Return the volume and surface area of the sphere(s) for the passed argument.
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its...
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = matrix_problem([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. The function should work...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
USING MATLAB Write a program called QuadProg that determines the roots of a quadratic equation. Use...
USING MATLAB Write a program called QuadProg that determines the roots of a quadratic equation. Use functions to implement each action. Zip you directory of *.m files into a single file and turn this in on BBLearn under Class Activities. QuadProg write a function called getInputs to get a single input value. write a function called findDiscriminant write a function called findDenominator write a function called findRoot which will be used for both roots write a function called displayResults displayResults...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except for 1s on the reverse diagonal from top right to bottom left. The reverse diagonal of an n-by-n matrix consists of the elements at the following indexes: (1, n), (2, n-1), (3, n-2), … (n, 1). The function takes one positive integer input argument named n, which is the size of the matrix, and returns the matrix itself as an output argument. Note that...
1) A nozzle is a device for increasing the velocity of a steadily flowing stream of...
1) A nozzle is a device for increasing the velocity of a steadily flowing stream of fluid. At the inlet to a certain nozzle the enthalpy of the fluid is 3025 kJ/kg and the velocity is 60 m/s. At the exit from the nozzle the enthalpy is 2790 kJ/kg. The nozzle is horizontal and there is negligible heat loss from it. (i) Find the velocity at the nozzle exit. (ii) If the inlet area is 0.1 m2 and specific volume...
1. Find the area under the standard normal curve (round to four decimal places) a. To...
1. Find the area under the standard normal curve (round to four decimal places) a. To the left of  z=1.65 b. To the right of z = 0.54 c. Between z = -2.05 and z = 1.05 2. Find the z-score that has an area of 0.23 to its right. 3. The average height of a certain group of children is 49 inches with a standard deviation of 3 inches. If the heights are normally distributed, find the probability that a...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT