|
"Q Zhang" <silence_qunzi@hotmail.com> wrote in message <hck4k9$if$1@fred.mathworks.com>...
> Dear All,
>
> I was runing a loop in which every step generates a 3*1 vector as a result, and I need to store all these matrixes into a big one. Since the line and colum indices are mismatched with the result, the result doesn't comes out. Can anyone help me about it? Many thanks in advance?!
>
> Below is my loop:
> for i=1:n
> for j=1:m
> [mu(i,j),FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = ...
> fmincon(@myfun,mu0,[],[],[],[],lbe,ube,[],options,m2,m3(i),m4(i),w(j));
> end
> end
>
> mu=mu; %% should be a (3*n,3*m) matrix
>
> %% in each step of the loop, mu is a 3*1 vector
>
> QZ
Here are two possible ways:
1. make a cell array, so that A{i,j}=X, where X is the 3x1 matrix.
2. Expand your indices, so that:
Aindex=i*3 Bindex=j
P(Aindex,Bindex)=X, where X is the 3x1 matrix
The resulantant matrix mu should be (3*n,m)
|