|
"SM " <khanmoradi@gmail.com> wrote in message <hsbgq8$ct7$1@fred.mathworks.com>...
> > A = ceil(10*rand(3,4));
> > Ap = A';
> > j = 1; %can be 1, 2 or 3 for this 'A' matrix
> > y = Ap(1:j*4)';
> Actually, this only ordered the rows. What I want is something different.
>
> Assume A = ceil(10*rand(3,4)) generates the following matrix:
> A=[4 10 6 8
> 4 7 7 3
> 3 5 10 9]
> in case j=2, I want the following outcome:
> y= [4 4 10 7 6 7 8 3]
> (while the provided code gives y=[4 10 6 8 4 7 7 3])...
>
> is it possible to do this in matlab?
A = [4 10 6 8
4 7 7 3
3 5 10 9];
j=2;
Out = reshape(A(1:j,:),1,[])
Out =
4 4 10 7 6 7 8 3
Oleg
|