MATLAB Answers

how to create 2 vectors from a matrix

4 views (last 30 days)
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 Comment

Azzi Abdelmalek
Azzi Abdelmalek on 25 Mar 2013
In your case, harm is not a matrix, it's a vector

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 25 Mar 2013
harmx=harm(1:3:end)
harmy=harm(2:2end)

  0 Comments

Sign in to comment.

More Answers (0)