Question

1) ) Cubic equations of state can be used to establish the pressure(P)-volume(V)-temperature (T) relationship of fluids. A ty

I need to solve this using matlab.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code: MainV.m

clc
clear
%%initial guess
xl = 1;
xu = 3600;

fl = funVol(xl);
fu = funVol(xu);

%check if signs of fx and fu are different
if (fl*fu > 0)
error('Initial guesses should have different signs');
end
%%iterative solution using bisection rule
maxIter = 100;
tolX = 1e-6;
for i = 1:maxIter
err = abs(xl - xu);
xNew = (xl + xu)/2;
fNew = funVol(xNew);
if(fl*fNew > 0)
xl = xNew;
fl = fNew;
else
xu = xNew;
fu = fNew;
end
if (abs(err) < tolX)
break;
end
end
disp("Smallest root V0 = "+num2str(xNew));

Code: funVol.m

function fvol = funVol(V)
R = 83.14;
T = 350;
P = 9.46;
a = 2.9*10^8;
b = 807;
fvol = V^3 - R*T/P *V^2 - (b^2 + b*R*T/P - a/(P*sqrt(T)))*V - a*b /(P*sqrt(T));

end

Output:

Command Window Smallest root VO 3594.2944 fx >>

Add a comment
Know the answer?
Add Answer to:
I need to solve this using matlab. 1) ) Cubic equations of state can be used to establish the pressure(P)-volume(V)-tem...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT