hello i need to write script mathlab to make a matrix with vector v=[1 2 3 4]
2 次查看(过去 30 天)
显示 更早的评论
the output is [1 1 1 1;2 4 8 16;3 9 27 81;4 16 64 256]
采纳的回答
Awais Saeed
2021-12-11
Seems you want to have powers from 1 to 4
v = 1:4;
bsxfun(@power,v(:),[1:4]) % poers ranging from 1 to 4
6 个评论
Awais Saeed
2021-12-11
- Take transpose of vector a to make it a row vector.
- Take square of a and put the result in second column
- Take cube of a and put the result in third column.
- Use index of for loop with .^ to take square, cube, etc
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!