필터 지우기
필터 지우기

How do I assign rows of a matrix to an array?

조회 수: 40 (최근 30일)
Phil Whitfield
Phil Whitfield 2017년 10월 8일
편집: jean claude 2017년 10월 8일
So I have a Matrix, say A =[1,2,3;4,5,6;7,8,9]
I need to create an array of [4,5,6;7,8,9]
I have been trying a thousand variations of B= num2cell(A(2,:)) and B= num2cell(A(3,:))
but all I can create is obviously just an array of either 4,5,6 or 7,8,9 not them combined.
Any advice?

채택된 답변

Image Analyst
Image Analyst 2017년 10월 8일
Don't mess with cells - too complicated. Just index the rows:
b = A(2:3, :) % Extract rows 2 to 3 only.

추가 답변 (1개)

jean claude
jean claude 2017년 10월 8일
편집: jean claude 2017년 10월 8일
B= num2cell(A(2:3,:))
  댓글 수: 1
jean claude
jean claude 2017년 10월 8일
편집: jean claude 2017년 10월 8일
2:3 means from 2nd row until 3rd row of that matrix

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by