Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 16 Oct 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 commentaires
Torsten
le 16 Oct 2023
Modifié(e) : Torsten
le 17 Oct 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
le 17 Oct 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})
Voir également
Catégories
En savoir plus sur Formula Manipulation and Simplification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!