How to get two adjacent columns in loop

1 visualización (últimos 30 días)
MATRIX
MATRIX el 1 de Abr. de 2016
Comentada: MATRIX el 2 de Abr. de 2016
I have 201x1024 matrix with first column holding frequency second column holding real part and third column imaginary part then fourth column real and fifth imaginary and so on till last column only first column has frequency .I wish to convert that real and imaginary part into complex quantity or i with to have matrix of complex quantity.I will need loop to read that columns . i did this but its not working for column = 2:2:cols; subdata = DATA( :,column)+ 1i*DATA(:,column+1);
end
for column=2:2:col-1 ;
subdata = DATA( :, column:column+1);
c = complex(subdata (:,1),subdata (:,2));
end
subdata[1:No_rows,1:No_col]= DATA( 1:No_rows, column:column+1); c = complex(subdata (:,1),subdata (:,2)); A=abs(c);

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Abr. de 2016
a=[0 1 2 3 4 5 6;1 7 8 9 10 11 12;2 13 14 15 16 17 18]
freq=a(:,1)
v1=a(:,2:2:end);
v2=a(:,3:2:end);
v=v1+j*v2

Más respuestas (1)

Elias Gule
Elias Gule el 1 de Abr. de 2016
You need not use a for loop for this.
rData = DATA(:,2:2:end-1) % Get all the real data col 2,4,6...1022
iData = DATA(:,3:2:end-1) % Get all the imaginary data col 3,5,7,...1023
cData = complex(rData,iData) % Create A Matrix of complex data

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by