Why is my plot blank
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Chunru
2022-10-27
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)
更多回答(0 个)
另请参阅
类别
Find more on 2-D and 3-D Plots in Help Center and File Exchange
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!