How to create a loop on matrix

조회 수: 2 (최근 30일)
Vincent Ogonda
Vincent Ogonda 2020년 8월 13일
댓글: hosein Javan 2020년 8월 13일
Assuming you have a 4x10 matrix. How do you create a loop from the 2nd column of the matrix to the 10th column.

채택된 답변

hosein Javan
hosein Javan 2020년 8월 13일
편집: hosein Javan 2020년 8월 13일
for example suppose we want to multiply each column by its coulmn number:
A =[
92 99 1 8 15 67 74 51 58 40
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
]
for it=2:10
A(:,it) = A(:,it)*it;
end
A
A =
92 198 3 32 75 402 518 408 522 400
98 160 21 56 80 438 385 456 576 410
4 162 264 80 110 324 392 504 630 470
85 174 57 84 15 360 434 552 639 280
  댓글 수: 2
Vincent Ogonda
Vincent Ogonda 2020년 8월 13일
Do you have any idea how to update a vector using equation of a straight line X = [380 250 220 200] Update vector X using X = Cx + b and plot the results
hosein Javan
hosein Javan 2020년 8월 13일
if I understant correctly.
C=1; B=2;
X = [380 250 220 200]
Y = C*X+B
plot(X,Y)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by