At the line you are encountering the error, your "iN" is going to be a scalar. You are assigning to "result(iN)" which designates a scalar location. You would get the error,
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> LLT_run at 12 result(iN) = LLT_type2(b,N(iN),c,a,alpha,alphaoL,e,AR)
in the cast that what is on the right hand side does not return a scalar.
So we need to examine what is on the right hand side. The function declaration is
function[An,CL,delta,CDi,Gamma,Cl]=LLT_type2(b,N,c,a,alpha,alphaoL,e,AR)
outputs are assigned positionally, and since you only use one of the outputs, the one output that will be assigned to "result(iN)" is going to be the value of what is named "An" inside the function.
As we look back from the end of the function LLT_type2, we see that "An" is assigned a value in the statement,
What size is that? Well, IC is N by N, and RHS is ... ah, we cannot tell hat size RHS is with the information given. If the c, a, alpha, alphaoL are all scalars then RHS is N by 1, but the code would also work if those variables start out as column vectors of the same size P by 1, in which case RHS would be N by P.
If the noted variables were scalars, then
would have a result that was (N by 1), a column vector. That would only be able to fit into the scalar result(iN) if N was 1.
If the noted variables were P x 1 column vectors, then
would have a result that was N by P... which is not going to fit into the scalar result(iN) unless N and P are both 1.
I could show you have to construct "result" to be the right size to allow assignment from the loop, but somehow I suspect that you do not really want an to be the value returned from the function. Gamma or C1 look more plausible as the result you would want returned.
Best Answer