Hi, can you help me fix my code? How can I convert this to a matrix using if/while/for statements?
1 次查看(过去 30 天)
显示 更早的评论
format long G
MERfgh = [];
i = 1;
%for i=1:11
MERfgh(i,1) = MERfff(i,1);
for j=1:11
MERfgh(i,2) = MERfff(j,1);
i = i+1;
end
%end
MERfgh
I WANT IT TO LOOK LIKE THIS:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1425258/image.png)
0 个评论
回答(2 个)
DGM
2023-7-3
Consider the example:
% some data in a column vector
MERfff = (21:31).';
% rearrange it
[xx yy] = meshgrid(MERfff);
MERfgh = [xx(:) yy(:)]
1 个评论
James Tursa
2023-7-3
Also consider this example using element-wise raise-to-power:
10.^(-1:1)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!