how to create 2X10000 matrix using for loop in matlab

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

Answers (3)

Image Analyst
Image Analyst on 12 Aug 2014
Edited: Image Analyst on 12 Aug 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 on 12 Aug 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 on 12 Aug 2014
x0 = reshape(X,2,[]);
x1 = [x0(1,:);-conj(x0(2,:))];
x2 = [x0(2,:);conj(x0(1,:))];
tX = [x1(:).';x2(:).'];
  1 Comment
Kishore
Kishore on 14 Aug 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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!