how to create 2X10000 matrix using for loop in matlab

2 visualizzazioni (ultimi 30 giorni)
Kishore
Kishore il 12 Ago 2014
Commentato: Kishore il 14 Ago 2014
I am trying to create a matrix of size 2X10000 using for loop ie If
X={x1 x2 x3 x4 x5 x6 x7 x8 x9 x10............}
them my
tX1=[x1 -x2* x3 -x4* x5 -x6* ...........] row 1 from matrix in for loop
tX2=[x2 x1* x4 x3* x6 x5* ...........] row 2 from matrix in for loop

Risposte (3)

Image Analyst
Image Analyst il 12 Ago 2014
Modificato: Image Analyst il 12 Ago 2014
Seems pretty easy, assuming * means complex conjugate. Did you try anything like this
for k = 1 : 2 : length(X)-1
tX1(k) = X(k);
tX1(k+1) = -conj(X(k+1)); % Negative complex conjugate.
tX2(k) = X(k+1);
tX2(k+1) = conj(X(k));
end

dpb
dpb il 12 Ago 2014
Given an x vector of length 20003,
X=[x(1) -x(2:2:end-2).*x(3:2:end-1); ...
x(2) x(1:2:end-3).*x(4:2:end)]

Andrei Bobrov
Andrei Bobrov il 12 Ago 2014
x0 = reshape(X,2,[]);
x1 = [x0(1,:);-conj(x0(2,:))];
x2 = [x0(2,:);conj(x0(1,:))];
tX = [x1(:).';x2(:).'];
  1 Commento
Kishore
Kishore il 14 Ago 2014
Thank u andrei bobrov this block should work within for loop ie i need to convert 1XN matrix to 2XN matrix using for loop

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by