compex vector in 'C' -> complex vector in 'octave'
James Sherman Jr.
shermanj at umd.edu
Thu Apr 24 13:33:43 CDT 2008
I'm not sure how "elegant" it is, but I'd just do
y = x(1:2:end) + x(2:2:end)*i;
The best solution is probably just put this in your own
"read_complex_vector" function and just use that whenever you want to
read in that file format.
Hope this helps.
On Thu, Apr 24, 2008 at 2:14 PM, Sergei Steshenko <sergstesh at yahoo.com> wrote:
> Hello All,
>
> supposed I have a complex vector generated by a 'C' program and dumped in binary form into a file
> using 'fwrite'.
>
> So, the data will put into the file this way:
>
> re[0], im[0], re[1], im[1], ... re[N-1], im[N-1]
>
> where N is number of elements in the vector.
>
> I can load the vector into octave using 'fread', but, I quess, it will look like vector
> of real numbers.
>
> I can take data at indexes 1, 3, 5... (the real parts) and at indexes 2, 4, 6 ... (the imaginary
> parts) and "reconstitute" the vector, but maybe there is a handy function which already does
> this ?
>
> I read
>
> http://www.gnu.org/software/octave/doc/interpreter/Rearranging-Matrices.html#Rearranging-Matrices
>
> but could come up with anything more elegant than the straightforward odd-even indexes solution.
>
> Thanks,
> Sergei.
>
> Applications From Scratch: http://appsfromscratch.berlios.de/
>
>
>
> ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> _______________________________________________
> Help-octave mailing list
> Help-octave at octave.org
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
More information about the Help-octave
mailing list