"Babak " <b_mn@hotmail.com> wrote in message <ktipan$42$1@newscl01ah.mathworks.com>...
> "Yasser " <yasserzahedi@gmail.com> wrote in message <kti7er$mfp$1@newscl01ah.mathworks.com>...
> > Hello All,
> >
> > I have a matrix, let say H=rand(5), and I want to find the maximum value in each column. Then, getting the elements from the maximum value till the end of the column and saving the values.
> > I wrote the code as :
> >
> > H=rand(5)
> > for j= 3:size(H,2)
> > [i,j]=find (H==max(H(:,j))) % find the location of the maximum value in each column
> > D(:,j-2)=H(i:size(H,1),j) % Getting the new matrix columns
> > end
> >
> > When I run it, I got "Subscripted assignment dimension mismatch."
> >
> > I think the problem is in D(:,j-2).
> >
> > Anyone knows how to solve this ?
> >
> > Thank you
> > Yasser
>
>
>
>
> When you get the max of each column, then you have several rows not columns.
> you can write it very simple
>
> max_in_rows=max(H);
> max_in_columns=max(max_in_rows);
>
> Babak
Thank you Babak
Yasser
> "Yasser " <yasserzahedi@gmail.com> wrote in message <kti7er$mfp$1@newscl01ah.mathworks.com>...
> > Hello All,
> >
> > I have a matrix, let say H=rand(5), and I want to find the maximum value in each column. Then, getting the elements from the maximum value till the end of the column and saving the values.
> > I wrote the code as :
> >
> > H=rand(5)
> > for j= 3:size(H,2)
> > [i,j]=find (H==max(H(:,j))) % find the location of the maximum value in each column
> > D(:,j-2)=H(i:size(H,1),j) % Getting the new matrix columns
> > end
> >
> > When I run it, I got "Subscripted assignment dimension mismatch."
> >
> > I think the problem is in D(:,j-2).
> >
> > Anyone knows how to solve this ?
> >
> > Thank you
> > Yasser
>
>
>
>
> When you get the max of each column, then you have several rows not columns.
> you can write it very simple
>
> max_in_rows=max(H);
> max_in_columns=max(max_in_rows);
>
> Babak
Thank you Babak
Yasser