From: Snow White on
i have tried using this...

[x y z]=size(phi);
polang=transpose(polang);
p_ang=permute(reshape(repmat(polang,1,x*y),length(polang),x,y),[2 3 1]);

"Snow White" <gulesaman(a)gmail.com> wrote in message <hstrtq$rkp$1(a)fred.mathworks.com>...
> i tried it as follows
>
> a=[1 0]
>
> a = 1 0
>
> M=reshape(a,3,2*2*10,2);
> ??? Error using ==> reshape
> To RESHAPE the number of elements must not change.
> and the above error
>
>
> TideMan <mulgor(a)gmail.com> wrote in message <1da1eddd-078d-4a52-88d9-bb02624f1e48(a)g5g2000pre.googlegroups.com>...
> > On May 18, 10:23 pm, "Snow White" <gulesa...(a)gmail.com> wrote:
> > > hello,
> > >
> > > i have a row vector of length p. i want to transform it to a 3d matrix where the there r 3 row each row should be similar to the previous row (they are just copies). number of columns is pmn where mn is the size of another matrix and the depth of the resultant matrix is p.
> > >
> > > how can i do this?
> > >
> > > bye
> >
> > You can't.
> > The row vector,say R, must be 3*pmn*p long.
> > Then:
> > M=reshape(R,3,pmn,p);
From: Walter Roberson on
Snow White wrote:

> i have a row vector of length p. i want to transform it to a 3d matrix
> where the there r 3 row each row should be similar to the previous row
> (they are just copies).

See repmat()
From: Steven Lord on

"Snow White" <gulesaman(a)gmail.com> wrote in message
news:hsu640$9pq$1(a)fred.mathworks.com...
>I want [a] to be arranged such that the resultant matrix has three rows and
>pmn columns and the depth of the matrix is p which is the length of vector
>a.so in the third dimension the first dimension will have all ones and then
>the second will have 0s and so on..
>
> actually i have a vector p=[1,2,3,4,5...19]
>
> i hope i cam clear enough

I think I understand what you're asking for, but what I asked for was the
specific result that you expected.

Okay, let's do something a little different. Let's assume that we have a
function called snowwhite that does what you want. When I call that
function:

a = [1 2 3 4];
b = snowwhite(a)

I want you to state EXPLICITLY what the contents of b are. Complete the
statement below so that it creates EXACTLY the array b that you want
snowwhite(a) to return. If you need to define other variables first so that
you can use them in the statement that defines b, that's fine but you must
include them as part of the code you write in your reply.

b = cat(3, [

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Snow White on
i want b to be as follows:

b(:,:,1)=[1 1 1;1 1 1...]
b(:,:,2)=[2 2 2;2 2 2...]
b(:,:,4)=[4 4 4;4 4 4...]

"Steven Lord" <slord(a)mathworks.com> wrote in message <hsu7k1$m0m$1(a)fred.mathworks.com>...
>
> "Snow White" <gulesaman(a)gmail.com> wrote in message
> news:hsu640$9pq$1(a)fred.mathworks.com...
> >I want [a] to be arranged such that the resultant matrix has three rows and
> >pmn columns and the depth of the matrix is p which is the length of vector
> >a.so in the third dimension the first dimension will have all ones and then
> >the second will have 0s and so on..
> >
> > actually i have a vector p=[1,2,3,4,5...19]
> >
> > i hope i cam clear enough
>
> I think I understand what you're asking for, but what I asked for was the
> specific result that you expected.
>
> Okay, let's do something a little different. Let's assume that we have a
> function called snowwhite that does what you want. When I call that
> function:
>
> a = [1 2 3 4];
> b = snowwhite(a)
>
> I want you to state EXPLICITLY what the contents of b are. Complete the
> statement below so that it creates EXACTLY the array b that you want
> snowwhite(a) to return. If you need to define other variables first so that
> you can use them in the statement that defines b, that's fine but you must
> include them as part of the code you write in your reply.
>
> b = cat(3, [
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
From: Steven Lord on

"Snow White" <gulesaman(a)gmail.com> wrote in message
news:hsu9tt$r8j$1(a)fred.mathworks.com...
>i want b to be as follows:
>
> b(:,:,1)=[1 1 1;1 1 1...]
> b(:,:,2)=[2 2 2;2 2 2...]
> b(:,:,4)=[4 4 4;4 4 4...]

That's getting _closer_ to what I asked for, but you're still not there.
SPECIFICALLY how many columns do you want b to have?



I believe what you want, assuming you know how many rows and columns you
want, is:

b = repmat(reshape(a, 1, 1, []), numRows, numCols, 1)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ