Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to create a matrix with increasing power?
Replies: 9   Last Post: Feb 28, 2014 10:06 AM

 Messages: [ Previous | Next ]
 Curious Posts: 2,359 Registered: 12/6/04
Re: How to create a matrix with increasing power?
Posted: Feb 21, 2014 5:03 PM

"Sven " <svendotholcombe@gmaildot.com> wrote in message <le8g3t\$7kg\$1@newscl01ah.mathworks.com>...
> "Timothy Liang" <timothy.tliang@gmail.com> wrote in message <le8e48\$1uu\$1@newscl01ah.mathworks.com>...
> > I just started to learn how to use matlab... Just a simply question...
> >
> > Is there a simple way create a matrix like this?
> > x= 1, 2, 3, 4, 5
> >
> > matrix X=1^0 1^1 1^2 1^3
> > 2^0 2^1 2^2 2^3
> > 3...
> > 4...
> > 5...
> >
> > Thanks!!

>
> Yep, try this:
>
> bsxfun(@power, 0:5, (1:5)')
> ans =
>
> 0 1 2 3 4 5
> 0 1 4 9 16 25
> 0 1 8 27 64 125
> 0 1 16 81 256 625
> 0 1 32 243 1024 3125

I don't think this is what Timothy asked for.

If I understand the OP he wants a 4X5 matrix where given:

x = 1:5
y = 10^(0:3)

for ii = 1:length(x)
X(:,ii) = x(ii)*y;
end

I don't have MATLAB installed on this computer,
but the result should be:
X= [
1 1 2 3
1 2 4 8
1 3 9 27
1 4 16 64
1 5 25 125]

which is what I believe the OP asked for. (Maybe its transposed.)

I know there are more MATLAB efficient ways,
but Timothy did ask for a SIMPLE way.

Date Subject Author
2/21/14 Timothy Liang
2/21/14 Sven
2/21/14 Timothy Liang
2/21/14 Curious
2/21/14 Curious
2/21/14 John D'Errico
2/22/14 Curious
2/22/14 Timothy Liang
2/22/14 Timothy Liang
2/28/14 SEOLSRON