for loop for variables

1 回表示 (過去 30 日間)
Ali
Ali 2020 年 11 月 23 日
回答済み: Ali 2020 年 11 月 30 日
can anybody tell how can run this code. I wan to find volume varition that depenf on Xd and Xp
q=1.4
Ad=1.9625*10^-3;
Ap=9.4985*10^-5;
kd=3985;
md=0.0023;
wd=((2*9.81)/0.140)^0.5;
wp=(kd/md)^0.5;
Sd=0.004;
Sp=0.003;
Xd=0.04;
Xp=1;
0=90;
for t=0:100
xd(t)=Xd*sin(wd*t);
xp(t)=Xp*sin(wp*t-o);
v1=Ad*Sd-Ad*xd(t);
v11=(Ad-Abd)*Sd+Sp*Ap+(Ad-Abd)*xd(t)-Ap*xp(t);
end

採用された回答

Alan Stevens
Alan Stevens 2020 年 11 月 23 日
You probably want o = 90; not 0 = 90;
Also, Matlab indexing starts at 1 not zero, so, perhaps, t = 1:101, then xd(t) = sin(wd*(t-1)); etc.
To save all values of v1 you want v1(t) = ... Similarly for v11
You also need to define Abd.

その他の回答 (1 件)

Ali
Ali 2020 年 11 月 30 日
>> Sir kindly tell me what is error in this program??
q=1.4;
Ad=1.9625*10^-3;
Ap=9.4985*10^-5;
Abd=7.85*10^-5
kd=3985;
md=0.0023;
wd=((2*9.81)/0.140)^0.5;
wp=(kd/md)^0.5;
Sd=0.004;
Sp=0.003;
Xd=0.04;
Xp=1;
o=90;
p=101325;
T1=800;
T2=300;
v=4.225*10^-4;
R=8.137;
vi=Sd*Ad;
vii=Sp*Ap;
cp=1.005;
cv=0.718;
dt=0.1;
for t=1:101
xd(t)=Xd*sin(wd*(t-1));
xp(t)=Xp*sin(wp*(t-1)-o);
v1(t)=Ad*Sd-Ad*xd(t);
v11(t)=(Ad-Abd)*Sd+Sp*Ap+(Ad-Abd)*xd(t)-Ap*xp(t);
a1(t)=-q*p*(v1(t)/T1+v11(t)/T1);
a2(t)=(v1/T1+q*(v/T1+v/T1+v/T1+v/T1+v/T1+v/T1+v/T1+v/T1+v/T1)+v11/T1);
dp(t)=a1/a2;
dm1(t)=(p*v1(t)+vi*dp/q)/(R*T1);
dm11(t)=(p*v11(t)+vii*dp/q)/(R*T2);
for i=2:10
dmi=vi*dp/RTi
dmi/dt=m(i-1)-dmi/dt
Tfi=cp*((mf,i-1*Tf,i-1)-(mf,i+1*Tf,i+1))/cv*dmi/dt
end
m12=-dm1(t)/dt;
m1011=dm11(t)/dt;
Tf1=[-cp*m12*T1-p*(v1(t)/dt)]/(cv*m12);
Tf11=[-cp*m1011*T2-p*(v11(t)/dt)]/(cv*m1011);
end
Abd =
7.8500e-05

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by