need to plot this question

1 次查看(过去 30 天)
Nai Mansoor
Nai Mansoor 2015-3-31
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 个评论
Nai Mansoor
Nai Mansoor 2015-3-31
编辑:James Tursa 2015-3-31
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

请先登录,再进行评论。

回答(1 个)

Michael Haderlein
编辑:Michael Haderlein 2015-4-1
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 个评论
Nai Mansoor
Nai Mansoor 2015-4-1
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
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).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by