필터 지우기
필터 지우기

how to create 2 vectors from a matrix

조회 수: 1 (최근 30일)
tony karamp
tony karamp 2013년 3월 25일
hello all,
I have a matrix called harm and I would like to create 2 vectors from that matrix, harmx and harmy. harmx would have the components i=1,3,5....39 while harmy will have i = 2,4,6...40.
I tried that, but it said that the Index exceeds the matrix dimensions
harmx []
harmy []
for i=1:40
if mod(i,2) == 0
harmx = harm(i);
else
harmy = harm(i);
end
end
Thank you in advance!
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 25일
In your case, harm is not a matrix, it's a vector

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 25일
harmx=harm(1:3:end)
harmy=harm(2:2end)

추가 답변 (0개)

카테고리

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