Would like to create a 2x3 matrix using for loop

2 次查看(过去 30 天)
pnh3=.046; %%torr
po2=.068; %%torr
R1=1.987 ; %%cal/gmol*K
R=62.364; %%torr L/gmol K
vo=100/3600; %%L/s
T=zeros(3,1);
T(1)=473;
T(2)=673;
T(3)=800;
z=Ljallo_f1_q1(T,R1,pnh3,po2);
fio=Ljallo_f2_q1(T,R,vo,pnh3,po2);
function iFlows=Ljallo_f2_q1(T,R,vo,pnh3,po2)
cnh3=zeros(3,1);
finh3o=zeros(3,1);
co2=zeros(3,2);
fio2o=zeros(3,2);
iFlows=zeros(3,2);
for i=1:3
cnh3(i,1)=pnh3/(R.*T(i));
finh3o(i,1)=cnh3(i,1).*vo;
iFlows=finh3o(i,1);
co2(i,2)=po2/(R.*T(i));
fio2o(i,2)=co2(i,2).*vo;
iFlows=fio2o(i,2);
end
>> Ljallo_s_q1
>> fio
fio =
3.7860e-08
>>
I want to create a 2x3 matrix for 'fio'. however, when I call it I get one anwser.

采纳的回答

Matt J
Matt J 2020-4-14
编辑:Matt J 2020-4-14
This line has an error,
iFlows=fio2o(i,2);
The right hand side fio2o(i,2) is a scalar, but there is no indexing on the left hand side to tell where in iFlows it should be assigned to. So, the whole array iFlows simply gets overwritten.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by