hello i need to write script mathlab to make a matrix with vector v=[1 2 3 4]

1 view (last 30 days)
Mohamad  Haj
Mohamad Haj on 11 Dec 2021
Commented: Mohamad Haj on 11 Dec 2021
the output is [1 1 1 1;2 4 8 16;3 9 27 81;4 16 64 256]

Accepted Answer

Awais Saeed
Awais Saeed on 11 Dec 2021
Seems you want to have powers from 1 to 4
v = 1:4;
bsxfun(@power,v(:),[1:4]) % poers ranging from 1 to 4
ans = 4×4
1 1 1 1 2 4 8 16 3 9 27 81 4 16 64 256
  6 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by