How to solve for a vector in an equation with vectors?

1 次查看(过去 30 天)
function[v,Z] = Ideal_Gas_Law(R,T,P,Tc,Pc)
format short
% Version 1: created 24/04/19. Author: Paul Curran
% Version 2: created 06/02/20. Author: Savana Stewart
Iteration_limit= 20; % maximum number of iterations permitted
Tolerance=10^-7; % maximum acceptable value for modulus of
% function evaluated at estimated root
R = 0.082057
T = 293
P = [1,1.5,2,2.5,3,5,10,15,25,50,100]
Tc = 416.90
Pc = 78.72918
a = ((R^2)*(Tc^(5/2)))/(9*Pc*(2^(1/3)-1))
b = (R*Tc*(2^(1/3)-1))/(3*Pc)
A = (a*P)/((R^2)*(T^(5/2)))
B = (b*P)/(R*T)
syms Z
eqn = (Z.^3) - (Z.^2) + (A-B-(B.^2)).*Z - (A.*B) == 0
solZ = solve(eqn,Z)
Z
syms v
eqn2 = (v/(v - b)) - (a/(R*(T^(3/2))*(v+b))) == Z
solv = solve(eqn2,v)
%fprintf('%d\n',v)
%if Pv_RT1 == Pv_RT2
% fprintf('The two forms of the equations given are equivalent');
%else
% fprintf('not equal')
% return
end
I am trying to find numerical values for Z to then plug into eqn2 to solve for v. I am having trouble solving for Z. What am I doing wrong? Please keep in mind I am a Matlab beginner.
Is there a way to use Regula-Falsi or the Newton-Raphson algorithm to do this?

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by