hi,
i want to add to a matrix edhe next element to the next column
e.g
calculate an element
add to position matrix(1,1)
calculate next element
add to position matrix(1,2)
...
jump to next row and do the same ...

댓글 수: 1

Hints:
element=calculate the element
for i=1:r
for j=1:c
mat(i,j)=element
element=calculate the element
end
end

댓글을 달려면 로그인하십시오.

 채택된 답변

M
M 2019년 11월 20일

0 개 추천

You can read this to know about matrix indexing:
You can do something like:
m = nbRow;
n = nbCol;
M = zeros(m,n);
for i = 1 : nbRow
for j = 1 : nbCol
a = i + j ;% some calculation
M(i,j) = a;
end
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2019년 11월 20일

댓글:

2019년 11월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by