for loop problem with matrix

조회 수: 1 (최근 30일)
Rica
Rica 2013년 5월 22일
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?

채택된 답변

Iain
Iain 2013년 5월 22일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by