for loop problem with matrix

1 Ansicht (letzte 30 Tage)
Rica
Rica am 22 Mai 2013
Hi all!
I have matrix 'Input' with the size of 1024*10
i wrote a matlab program just for one vector input(:,1). the programm is:
n1=1024
xx=reshape(Input(:,1),4,n1/4);
x_r=[xx(1,1:n1/4);-xx(3,1:n1/4)];
x_i=[xx(2,1:n1/4);-xx(4,1:n1/4)];
x_rr=reshape(x_r,1,n1/2);
x_ii=reshape(x_i,1,n1/2);
how could i do the same for alle other 9 vectors, possibly without for loop?

Akzeptierte Antwort

Iain
Iain am 22 Mai 2013
You could do it by using the THIRD dimension.
xx = reshape(Input,[4,nl/4,10]);
x_r = [xx(1,:,:);-xx(3,:,:)];
x_l = [xx(2,:,:);-xx(4,:,:)];
x_rr = reshape(x_r,[1,nl/2,10]);
... etc.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by