필터 지우기
필터 지우기

omitting array

조회 수: 1 (최근 30일)
Anahita Gh
Anahita Gh 2012년 2월 16일
편집: Jan 2013년 10월 14일
hi, i'm a beginner and now i'm writing a program, but there is a problem. i have a 13*1 matrix, but i want just the odd rows, it means 1, 3, 5, 7, 9, 11, and 13. how can i omit the even rows? i want a rule so that i can use it for other long matrixes! please help :D

채택된 답변

Laura Proctor
Laura Proctor 2012년 2월 16일
If your matrix is called m, you can reference the odd rows like this:
m(1:2:end,:)
If it is always going to be a vector (an nx1 or 1xn matrix), then you can use linear indexing and this reference:
m(1:2:end)
If you want to overwrite your vector, just reassign it to the original variable name:
m = m(1:2:end)
  댓글 수: 1
Anahita Gh
Anahita Gh 2012년 2월 16일
tnx :)

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

추가 답변 (1개)

Oleg Komarov
Oleg Komarov 2012년 2월 16일
I suggest you to read the chapter "Matrices and Arrays" from the Getting Started guide.
For matrix A:
A(1:3:end,:)
  댓글 수: 1
Anahita Gh
Anahita Gh 2012년 2월 16일
tnx :)

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by