Would like to create a 2x3 matrix using for loop
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rodrigo Blas
el 14 de Abr. de 2020
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.
0 comentarios
Respuesta aceptada
Matt J
el 14 de Abr. de 2020
Editada: Matt J
el 14 de Abr. de 2020
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Discrete Math en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!