for loop problem with matrix

6 visualizzazioni (ultimi 30 giorni)
Rica
Rica il 22 Mag 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?

Risposta accettata

Iain
Iain il 22 Mag 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.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by