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!