Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clc;clear;format compact;
syms V
P=[0.98 1.97 4.93 9.86 49.36 98.69]; %atm
T=[573 573 573 573 573 573]; %K
R=461.5; %Pa*m3/mol*K
R=convpres(R,'Pa','atm');
R=R*1000; %L*atm/mol*K
% Van der Waals
Tc=647.1;
Pc=convpres(22060000,'Pa','atm');
a1=(27*R^2*Tc^2)/(64*Pc);
b1=(R*Tc)/(8*Pc);
VW=((R*T)/(V-b1))-(a1/(V^2))==P;
for i=1:6
B(1,i)=solve(VW(i),V)
end
0 Kommentare
Antworten (1)
Walter Roberson
am 16 Okt. 2023
clc;clear;format compact;
syms V
P=[0.98 1.97 4.93 9.86 49.36 98.69]; %atm
T=[573 573 573 573 573 573]; %K
R=461.5; %Pa*m3/mol*K
R=convpres(R,'Pa','atm');
R=R*1000; %L*atm/mol*K
% Van der Waals
Tc=647.1;
Pc=convpres(22060000,'Pa','atm');
a1=(27*R^2*Tc^2)/(64*Pc);
b1=(R*Tc)/(8*Pc);
VW=((R*T)/(V-b1))-(a1/(V^2))==P
for i=1:6
B{1,i}=solve(VW(i),V);
end
B
Your equation is a cubic in V, and so it has three roots.
format long g
cell2mat(cellfun(@double, B, 'uniform', 0))
Only one of the roots is real-valued -- but you asked to solve the equation, not to find real-valued solutions.
5 Kommentare
Torsten
am 16 Okt. 2023
Bearbeitet: Torsten
am 17 Okt. 2023
clc;clear;format compact;
syms V
P=[0.98 1.97 4.93 9.86 49.36 98.69]; %atm
T=[573 573 573 573 573 573]; %K
R=461.5; %Pa*m3/mol*K
R=convpres(R,'Pa','atm');
R=R*1000; %L*atm/mol*K
% Van der Waals
Tc=647.1;
Pc=convpres(22060000,'Pa','atm');
a1=(27*R^2*Tc^2)/(64*Pc);
b1=(R*Tc)/(8*Pc);
VW=((R*T)/(V-b1))-(a1/(V^2))==P
for i=1:6
B{1,i}=solve(VW(i),V);
end
format long g
M = cell2mat(cellfun(@double, B, 'uniform', 0))
for i = 1:size(M,2)
indices = find(abs(imag(M(:,i))) < 1e-6);
sol{i} = M(indices,i); % better save in cell array for the case of 3 real solutions
end
sol
Walter Roberson
am 17 Okt. 2023
Your last P has three real-valued solutions.
clc;clear;format compact;
syms V real
P=[0.98 1.97 4.93 9.86 49.36 98.69]; %atm
T=[573 573 573 573 573 573]; %K
R=461.5; %Pa*m3/mol*K
R=convpres(R,'Pa','atm');
R=R*1000; %L*atm/mol*K
% Van der Waals
Tc=647.1;
Pc=convpres(22060000,'Pa','atm');
a1=(27*R^2*Tc^2)/(64*Pc);
b1=(R*Tc)/(8*Pc);
VW=((R*T)/(V-b1))-(a1/(V^2))==P;
for i=1:6
B{1,i} = solve(VW(i),V, 'maxdegree', 3);
end
cellfun(@double, B, 'uniform', 0)
B{end}
format long g
double(B{end})
Siehe auch
Kategorien
Mehr zu Formula Manipulation and Simplification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!