how can i change Matrix last row with loop?

조회 수: 5 (최근 30일)
Jan Vidlak
Jan Vidlak 2020년 11월 14일
댓글: Setsuna Yuuki. 2020년 11월 15일
Hi there, i am a begginer in Matlab and i have problem with solving the matrix.. The problem is that i dont know how to change last row in matrix with numbers
[0 0 0 -1] - matrix one
[0 0 -2 -1] - matrix two
[0 -3 -2 -1] - matrix three
[-4 - 3 -2 -1] - matrix four
And here is my code:
for n = 2:5
A22 = eye(n, n-1);
A21 = zeros(n, 1);
A = [A21, A22];
end
(this code is working, i only need to change last row)

채택된 답변

Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 15일
this can work
for n = 2:6
A22 = eye(n, n-1);
A21 = zeros(n, 1);
A = [A21, A22];
end
A = A(1:5,:)
  댓글 수: 5
Jan Vidlak
Jan Vidlak 2020년 11월 15일
편집: Jan Vidlak 2020년 11월 15일
hey, i have one more question if you know it, the eye function gives me this: E = eig(A) <-- inside loop
Is that correct(numbers)?
Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 15일
i don't know if the result is correct, but the eigenvalues can be complex.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by