How can i run this code? I get erros "Unable to perform assignment because the size of the left side is 1-by-600 and the size of the right side is 1-by-100."
2 views (last 30 days)
Show older comments
%Plot P-V diagram of a given substance using van der Waals equation of states
%Substance properties are defined by the van der Waals constants and
%the critical properties.
clc; clear; close all;
Tc = 765.62; % R
Pc = 550.60; % psi
Vc = 4.086; % ft3/lbmole
R = 10.732; % psi ft3/(lbmole-R)
% van der Waals Equation of State Constants
% for Propane
a = 54565.6;
b = 1.9639;
V = linspace(b*1.2,40*Vc,100); % vector of volume
% temperature in F
T = [60 180 230 270 300 306];
T = T + 460; % temperature in R
H = [1.250 1.118 1.069 1.031 1.0049 0.999];
%van der Waals Equation
fvdWEOSp = @(Tx,Vx,Hx)(R*Tx./(Vx-b)-a*Hx./(Vx.^2 + 2*Vx*b-b^2));
P = zeros(numel(T), numel(V), numel(H));
for i= 1:numel(T)
Tx = T(i);
Hx = H(i);
P(i,:) = fvdWEOSp(Tx,V,Hx);
end
% plot(V,P); xlim([0 800]);
semilogx(V,P); xlim([1 800]);
ylim([0 2000]);
xlim([0 1000]);
xlabel('Volume, ft^3');
ylabel('Pressure, psi');
0 Comments
Answers (1)
Matt J
on 19 May 2022
for j=1:numel(H)
for i= 1:numel(T)
Tx = T(i);
Hx = H(j);
P(i,:,j) = fvdWEOSp(Tx,V,Hx);
end
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!