필터 지우기
필터 지우기

How to assign the result of a row deletion operation to a new matrix?

조회 수: 5 (최근 30일)
I have a 10X10 matrix, from which I delete the row 3 applying A(3,:)= [] . I want to save the original matrix and have the new matrix with a deleted row assigned to a new variable C. Now how do I assign this result to a new matrix C?
I do C= A(3,:)=[] but it is obviously wrong.
Thank you!

채택된 답변

Star Strider
Star Strider 2023년 1월 17일
I would do something like this —
A = magic(10) % Save Original
A = 10×10
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 86 93 25 2 9 61 68 75 52 34 17 24 76 83 90 42 49 26 33 65 23 5 82 89 91 48 30 32 39 66 79 6 13 95 97 29 31 38 45 72 10 12 94 96 78 35 37 44 46 53 11 18 100 77 84 36 43 50 27 59
C = A; % Copy 'A' To 'C'
C(3,:) = [] % Delete Row 3 From 'C'
C = 9×10
92 99 1 8 15 67 74 51 58 40 98 80 7 14 16 73 55 57 64 41 85 87 19 21 3 60 62 69 71 28 86 93 25 2 9 61 68 75 52 34 17 24 76 83 90 42 49 26 33 65 23 5 82 89 91 48 30 32 39 66 79 6 13 95 97 29 31 38 45 72 10 12 94 96 78 35 37 44 46 53 11 18 100 77 84 36 43 50 27 59
.
  댓글 수: 4
Ecaterina Savenco
Ecaterina Savenco 2023년 1월 17일
Oh sorry! It is the first time I ask a question on this forum, did not know that is the procedure. All done now^^ Thanks again!
Star Strider
Star Strider 2023년 1월 17일
As always, my pleasure!
No worries! That is the reason I asked .

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by