Indexing a Matrix with a for loop
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a matrix of complex numbers, z: z = [1+j 2+j 5+j;4+3j 6+2j 1+3j], and am trying to replicate z into y using a for loop. I thus have y = zeros(size(z));
My problem is that I do not know what to set i equal to in the for loop.
For example,
if I use
for i = size(z)
y(i) = z(i)
end,
i is only covering the output of the size. How can I make it such that i will include every matrix index?
댓글 수: 0
채택된 답변
madhan ravi
2019년 10월 17일
for ii = 1:numel(z) % don't name variables i or j (because they are interpreted as imaginary numbers by default)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!