Why is my plot blank

조회 수: 4 (최근 30일)
Dumisa Ndhlovu
Dumisa Ndhlovu 2022년 10월 27일
댓글: Dumisa Ndhlovu 2022년 10월 27일
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)

채택된 답변

Chunru
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
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
Dumisa Ndhlovu
Dumisa Ndhlovu 2022년 10월 27일
Thank you for your assistance. If you dont mind me asking, what was the fault in the initial code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Thermal Analysis에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by