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 CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by