MATLAB: How can i plot mol fraction NO on many combustions cycle

help

I generate 3 vectors for 3 phases of combustion :
NO1=zeros(size(t1,1),1); %" phase 1
NO2=Y1no; % where
Y1no=1e6*yno(:,1)./(yno(:,1)+yno(:,2)+yno(:,3)+yno(:,4)+yno(:,5)+yno(:,6)+yno(:,7)+yno(:,8)+yno(:,9)); % " phase 2
NO3=zeros(size(t3,1),1)+Y1no(end); %" phase 3
when i want to generate a vector with to column inside the boucle like
Y12no(:,i)=[NO1;NO2;NO3];
i have this error message : "Subscripted assignment dimension mismatch".
I don't understand, for other vectors it's works but mine no. Help me please, it's an understanding for me.
my version of matlab is '9.2.0.556344 (R2017a)' my license is …. thank you. I have only Optimazition toolbox

Best Answer

Can simplify code complexity significantly which helps in both writing and debugging in following line
Y1no=1e6*yno(:,1)./(yno(:,1)+yno(:,2)+yno(:,3)+yno(:,4)+yno(:,5)+yno(:,6)+yno(:,7)+yno(:,8)+yno(:,9));
as
Y1no=1e6*yno(:,1)./sum(yno(:,1:9),2);
keeping explicit row columns. If size(yno,2)==9, then simply
Y1no=1e6*yno(:,1)./sum(yno,2);
using the optional second DIM input argument for sum
The error is owing to the fact that whatever dimension Y12no is, its row dimension is not the same as the sum of the row dimensions for NO1, NO2, NO3 combined.
To illustrate:
>> y=zeros(3,1); % define a 3-vector
>> y(:,1)=[1;1]; % try to assign a 2-vector to it
Subscripted assignment dimension mismatch.
>>
gives the same error. You need to use debugger and check on the dimensions of each variable and determine where went wrong in which one(s) dimensions to make commensurate sizes for the operation.