0

I was assigned to do homework on the Math lab and to plot the graph but line is not showing up and graph is blank. Here is the code,

>> x=273:293:313;
>> y=100:150:200:250:300;
>> plot(x,y),x label('pressure'),y label('volume')
>> grid on
2
  • 1
    What are you plotting? There is only one x and an error on the y declaration. Commented Sep 5, 2017 at 1:20
  • Use MATLAB to make a plot of the ideal gas law, PV = nRT. To do so, make plots of the volume (on the y-axis) of one mole of gas (n = 1) as a function of pressure (on the x-axis) for temperatures of 273, 293, and 313 degrees Kelvin. Allow the pressure to vary between 100 kPa and 300 kPa in steps of 50 kPa. Note that R is the ideal gas constant, for which you can use a value of 8.314 J K-1 mol-1 . Make sure your plot uses units of Pa for pressure and m3 for volume. Make sure your plot is properly labeled, Commented Sep 6, 2017 at 1:19

1 Answer 1

1

So in Matlab the ":" operator denotes a range. For example, x = [1:20] would create an array of elements from 1-20. Furthermore, you can specify the "step" with which the array fills as well by doing x = [1:0.5:20] This will create an array with elements filling up from 1 to 20 by a step of 0.5 (x = 1,1.5,2,2.5 .... ,19.5,20).

So when you say in your code that x=273:293:313 you are specifying a range (273-313) with a step of 293! Matlab interprets this as an array with only one element: 273! This is because the next step in the array would be 293 more than the first element which is outside of the range specified. Therefore, if you simply want to list your elements in the array you can do so with spaces or commas: x = [273 293 313]. This will create an array with three elements.

The problem asks you to use the ideal gas law formula. The code you have provided isn't making use of the provided parameters! I don't want to give you the direct answer to your HW question without you demonstrating that you at least understand what they are asking for.

Sign up to request clarification or add additional context in comments.

1 Comment

Use MATLAB to make a plot of the ideal gas law, PV = nRT. To do so, make plots of the volume (on the y-axis) of one mole of gas (n = 1) as a function of pressure (on the x-axis) for temperatures of 273, 293, and 313 degrees Kelvin. Allow the pressure to vary between 100 kPa and 300 kPa in steps of 50 kPa. Note that R is the ideal gas constant, for which you can use a value of 8.314 J K-1 mol-1 . Make sure your plot uses units of Pa for pressure and m3 for volume. Make sure your plot is properly labeled,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.