Hello
I'm trying to create a 1000x1000 matrix in which each row is elevated to an ascending power. This is what I've got written down:
h=0;
for x=1:1:1000
v=1:1:1000;
w=[v.^x];
h=h+1;
end
A=ones(10,10)*w;
EXAMPLE: This is what I want for a 5x5 matrix:
v=1:1:10;
A=[v;v.^2;v.^3;v.^4;v.^5]

 Akzeptierte Antwort

KSSV
KSSV am 21 Okt. 2020
Bearbeitet: KSSV am 21 Okt. 2020

0 Stimmen

x = 1:5 ;
p = 1:5 ;
A = x'.^p ;
%%
A = repmat(x,5,1) ;
B = (A'.^p)'

3 Kommentare

Jonas Maes
Jonas Maes am 21 Okt. 2020
Now it puts 1 on the first row, 2 on the second, etc.
I want 1 2 3 4 5 on the first row, 1 4 9 16 25 on the second, etc.
KSSV
KSSV am 21 Okt. 2020
Edited the answer..check..
Jonas Maes
Jonas Maes am 21 Okt. 2020
Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 21 Okt. 2020

Kommentiert:

am 21 Okt. 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by