MATLAB Answers

adding element to a matrix row

5 views (last 30 days)
bbah
bbah on 20 Nov 2019
Commented: KALYAN ACHARJYA on 20 Nov 2019
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 Comment

KALYAN ACHARJYA
KALYAN ACHARJYA on 20 Nov 2019
Hints:
element=calculate the element
for i=1:r
for j=1:c
mat(i,j)=element
element=calculate the element
end
end

Sign in to comment.

Accepted Answer

M
M on 20 Nov 2019
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 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags