|
Thank you i realized that after i had posted the problem.
"Steven Lord" <slord@mathworks.com> wrote in message <hu9oru$49u$1@fred.mathworks.com>...
>
> "Snow White" <gulesaman@gmail.com> wrote in message
> news:hu6o4t$at1$1@fred.mathworks.com...
> > Hello,
> >
> > I have written the following code to parse a matrix of size 3x1549849,
> > each row to be converted to 19 matrices of size 271x301.
> > [Nr,Nc]=size(N);
> > Ncol=Nc/number_of_images;
> >
> > xcomp='Nx';ycomp='Ny';zcomp='Nz';
> > start_Ncol=1;
> > for(jj=1:number_of_images)
> > Nx=strcat(xcomp,int2str(jj));
> > Ny=strcat(ycomp,int2str(jj));
> > Nz=strcat(zcomp,int2str(jj));
> > Nx=N(1,start_Ncol:Ncol);
> > Ny=N(2,start_Ncol:Ncol);
> > Nz=N(3,start_Ncol:Ncol);
> > start_Ncol=Ncol+1;
> > Ncol=Ncol*(jj+1);
> > N_x(jj)=transpose(reshape(Nx,column,row));
> > N_y(jj)=transpose(reshape(Ny,column,row));
> > N_z(jj)=transpose(reshape(Nz,column,row));
> > end
> >
> > i get the following error
> > ??? In an assignment A(I) = B, the number of elements in B and
> > I must be the same.
>
> That's correct. On the last three lines of your FOR loop over jj, Nx, Ny,
> and Nz will each be row-by-column. However, jj is a scalar. Therefore
> you're trying to force a row-by-column matrix into ONE element of N_x, N_y,
> or N_z -- and you can't squeeze a matrix like that.
>
> Use a cell array or use an N-D array and fill in each page as appropriate:
>
> M = zeros(2, 3, 4);
> x = ceil(5*rand(2, 3));
> for k = 1:4
> M(:, :, k) = x.^k;
> end
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>
|