Clear Filters
Clear Filters

need to plot this question

3 views (last 30 days)
Nai Mansoor
Nai Mansoor on 31 Mar 2015
plot the compressibility chart using peng and robinson equation of state the values of Tr 1.0-1.5 (increment of 0.1) and Pr from 0-10 .. using the global for Pr and Tr
pc = 220.55
Tc = 647.1
  3 Comments
Nai Mansoor
Nai Mansoor on 31 Mar 2015
Edited: James Tursa on 31 Mar 2015
function [ y ] = PENG&ROBENSIO( z )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
global Pr
global Tr
Pc = 220.55; %bar
Tc = 647.1; % k
w = 0.345;
alpha = (1+(0.37464+1.54226*w-0.26992*w^2)*(1-sqrt(Tr)))^2;
yy = 0.45724;
omega = 0.0778;
q = yy*alpha/(omega*Tr);
b = omega*Pr/Tr;
e = 1-sqrt(2);
o = 1+sqrt(2);
y =(1+b-(q*b*(z-b)/((z+e*b)*(z+o*b))))-z;
end

Sign in to comment.

Answers (1)

Michael Haderlein
Michael Haderlein on 1 Apr 2015
Edited: Michael Haderlein on 1 Apr 2015
Please... Did you ever write this into the Matlab editor? If so, you would see that the error is in the very first line - you cannot have a & character in the function name.
Some more errors will appear running the program as Tr seems to be an array. You need element-wise operations here. Until you know you want matrix operations, you can simply replace all * by .*, all / by ./ and all ^ by .^ (the dots indicate element-wise operations).
What really surprises me is the fact that the use of the globals Pr and Tr seems to be part of the task. Is that really what your teacher wants you to do?
  2 Comments
Nai Mansoor
Nai Mansoor on 1 Apr 2015
yes i correct the error of the first line but the problem in the script file if i used fzero it always says that there is an error yes thats the teacher wants me to do am to confuse about it
Michael Haderlein
Michael Haderlein on 1 Apr 2015
Did you have a look on James' link? Right at the beginning it says:
---------------------------------------------------------
3) Show what you have attempted so far and if you have got:
  • an error then post the whole error message. We need ALL the red text, not just a small part snipped out of it. This means line numbers, actual lines of code that generated the error, traceback to prior functions, etc. - everything that is in red color.
---------------------------------------------------------
It costs our time to answer your questions, so please also invest time for reading links provided by the community (and follow the recommendations therein).

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!