Why is my plot blank

3 views (last 30 days)
Dumisa Ndhlovu
Dumisa Ndhlovu on 27 Oct 2022
Commented: Dumisa Ndhlovu on 27 Oct 2022
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)

Accepted Answer

Chunru
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
P = 1×3600
0 100.4854 100.5549 100.6243 100.6937 100.7631 100.8326 100.9020 100.9714 101.0409 101.1103 101.1797 101.2492 101.3186 101.3880 101.4574 101.5269 101.5963 101.6657 101.7352 101.8046 101.8740 101.9435 102.0129 102.0823 102.1517 102.2212 102.2906 102.3600 102.4295
%plot(t,P(t),'r--',"linewidth", 5)
plot(T,P,'r--',"linewidth", 5)
  1 Comment
Dumisa Ndhlovu
Dumisa Ndhlovu on 27 Oct 2022
Thank you for your assistance. If you dont mind me asking, what was the fault in the initial code.

Sign in to comment.

More Answers (0)

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!