How to read complex number from a *.csv file?

25 visualizaciones (últimos 30 días)
Ngoc
Ngoc el 5 de Dic. de 2013
Comentada: sixwwwwww el 5 de Dic. de 2013
Hi,
I have to import a data set from a csv file but I cannot find any way to import the complex number from the file to Matlab to do the data processing. I try to search on the internet but no solutions are helpful. I tried importdata, csvread, textread,... but they didn't work. Can anyone show me how to solve this problem? I attached part of my csv file below. I really need help. Thanks

Respuestas (2)

sixwwwwww
sixwwwwww el 5 de Dic. de 2013
you can do it as follows:
[num, str, raw] = xlsread('filename.csv');
a = str2num(cell2mat(raw));
  5 comentarios
Ngoc
Ngoc el 5 de Dic. de 2013
Here it is. This is only a small part that I cut from the file, which is too large to upload here.
sixwwwwww
sixwwwwww el 5 de Dic. de 2013
Use the following code on your data. It will work fine. I checked it for your sample data:
[num, str, raw] = xlsread('filename.csv');
rawval = double(cellfun(@(x) ~isnumeric(x), raw));
a = zeros(size(raw));
b = a;
a(rawval == 0) = cell2mat(raw(rawval == 0));
b(rawval == 1) = str2double(raw(rawval == 1));
Matrix = a + b;
I hope it helps. Good luck!

Iniciar sesión para comentar.


G A
G A el 5 de Dic. de 2013
https://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/239213

Categorías

Más información sobre Large Files and Big Data 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