Why is my plot blank
1 view (last 30 days)
Show older comments
The entire code itself works, but when it comes to plotting, it comes out blank. I've tried to adjust the linewidth, line color, and even marker specifiers, but nothing seems to change. There is no error message displayed, so I'm unsure on how to solve this issue.This is on Matlab2022a.
Please help, all suggestions are welcomed.
P0=300; %power of the heater
n=50;% amount of gas (mol)
M=28; % Molar mass of Nitrogen gas
m=n*M;% m is the mass of the gas(g)
m1=m/1000;% m1 is the mass of the gas(Kg)
Cp=1.04*1000; %Cp is the thermal heat capacity of the gas
V=1250;% V is the volume(L) of the container
R=8.314;
N=3600;
T(1)=298;
for t=2:1:N %t is time(s)
T(t)=P0/(m1*Cp)+T(t-1); %T(t) is the temperature of the gas (K)
P(t)=((n*R*T(t))/V).*1.01325;
while P(t)>200
P(t)=P(t)-0.1*P(t);
end
end
plot(t,P(t),'r--',"linewidth", 5)
0 Comments
Accepted Answer
Chunru
on 27 Oct 2022
P0=300; %power of the heater
n=50;% amount of gas (mol)
M=28; % Molar mass of Nitrogen gas
m=n*M;% m is the mass of the gas(g)
m1=m/1000;% m1 is the mass of the gas(Kg)
Cp=1.04*1000; %Cp is the thermal heat capacity of the gas
V=1250;% V is the volume(L) of the container
R=8.314;
N=3600;
T(1)=298;
for t=2:1:N %t is time(s)
T(t)=P0/(m1*Cp)+T(t-1); %T(t) is the temperature of the gas (K)
P(t)=((n*R*T(t))/V).*1.01325;
while P(t)>200
P(t)=P(t)-0.1*P(t);
end
end
P
%plot(t,P(t),'r--',"linewidth", 5)
plot(T,P,'r--',"linewidth", 5)
More Answers (0)
See Also
Categories
Find more on Thermal Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!