matlab如何在循环中吧循环次数写在图片上?

2025-04-06 06:56:24
推荐回答(1个)
回答1:

Pt比Pb、Ne少了一个的初值,你试一下,看可以不:
clc,clear,close all
% syms Rm Pb Rb;
Rm=input('燃料量:');
Ut=input('阀门开度:');
Pb(1)=16.7;
Ne(1)=313.22;
Rb(1)=47.12;
t=input('计算时间(s):');
for i=2:1:18;
Rb(1)=(-1*Rb(1)+Rm)/120*(i+1-i)+Rb(1);
end;
for i=2:1:t;
Rb(i)=(-1*Rb(i-1)+Rm)/120*(i+1-i)+Rb(i-1);
Pt(i)=Pb(i-1)-0.000455*(6.77*Rb(i))^1.3;
Pb(i)=(-0.2501*Pt(i)*Ut+6.77*Rb(i))/3266*((i+1-i))+Pb(i-1);
Ne(i)=(-1*Ne(i-1)+0.2501*Pt(i)*Ut)/12*((i+1-i))+Ne(i-1);
end
Pb
Ne
Pt;
n=1:i;
[ax,h1,h2]=plotyy(n,Pb,n,Ne);
grid on
xlabel('循环次数n');
set(get(ax(1),'Ylabel'),'String','Pb含量');
set(get(ax(2),'Ylabel'),'String','Ne含量');
效果:
燃料量:6539
阀门开度:0.8
计算时间(s):20

Pb =

Columns 1 through 15

16.7000 18.6809 20.7582 22.9313 25.1992 27.5612 30.0166 32.5644 35.2040 37.9346 40.7554 43.6656 46.6645 49.7514 52.9255

Columns 16 through 20

56.1861 59.5325 62.9639 66.4796 70.0789

Ne =

Columns 1 through 15

313.2200 286.7148 262.4080 240.1175 219.6769 200.9333 183.7468 167.9890 153.5423 140.2988 128.1598 117.0346 106.8403 97.5006 88.9459

Columns 16 through 20

81.1122 73.9409 67.3782 61.3749 55.8858