help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: load ascii data to octave(complex value)


From: Liam Groener
Subject: Re: load ascii data to octave(complex value)
Date: Tue, 09 Aug 2011 06:31:21 -0700


On Aug 9, 2011, at 5:12 AM, 손민경 wrote:

I have

'value.asc'

 as follows. (ascii)

  1      1.000000    0.000000
  2      0.157376   -0.987539
  3     -0.165522   -0.986206
  4      0.995348   -0.096349
  5      0.986746   -0.162273
  6      0.802929    0.596075
  7      0.629992   -0.776601
  8     -0.182941   -0.983124
  9     -0.434815   -0.900520
 10     -0.227926   -0.973678
 11     -0.030833   -0.999524
 12     -0.748147   -0.663533
 13      0.718962   -0.695050
 14      0.777737    0.628590
 15      0.340350    0.940299
 16      0.115246    0.993337

idummy  / real part / imaginary part

What I want to do is..

a construction 4*4 complex matrix A using those values.

A=[2+3i 1+2i -1+3i 3+3i; 
     3-1i 2-2i -2-3i 3-1i;
 ....

This is a semi-code about what I'm thinking..

open('values.asc')
for j=1,4
for k=1,4 //'because data is from 4*4 complex matrix
  read('values.asc') idummy, real, imaginary
  complexMatrixA(j,k)=(real)+(imainary)*i // or
  complexMatrixA(j,k)=cmplx(real,imaginary)

Hi,
It's not clear to me what order you want your complex numbers to be in the final matrix.
But how about something like:
a = load('value.asc');
z = complex(a(;,2),a(:,3));
z = reshape(z,4,4);
If you want the transpose of z instead:
z = z';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]