MATLAB Answers

¿Cómo puedo importar una señal que tengo guardada en formato csv?

63 views (last 30 days)
El problema que tengo es que ya hice las mediciones y estan guardadas en formato csv, ahora bien, quiero hacer un código que me permita abrir el explorador de windows para elegir la carpeta de origen de mis archivos, luego que me permita importar un archivo xxx.csv que tiene 8 filas de encabezado (En la fila 9 empiezan mis datos) y crear una variable para cada una de las dos columnas de mi información (Vector de tiempo y vector de datos). Como puedo hacerlo, o existe otro método?
Gracias a todos.
The problem I have is that I did the measurements and are saved in csv format, however, I have a code that allows me to open the Windows Explorer to select the source folder of my files, then allow me to import a file xxx . csv, who is 8 header row (row 9 start As my Data) and create a variable for each of the two columns of my information (time vector and vector of data). How I can do, or does there another method?
Thank you all.

  0 Comments

Sign in to comment.

Accepted Answer

Anathea Pepperl
Anathea Pepperl on 23 Mar 2011
You can either use csvread or textscan. With csvread, you can use:
data = csvread('xxx.csv', 9, 0)
var1 = data(:,1);
var2 = data(:,2);
so that you start reading data on row 9, column 0 in order to avoid reading the 8 header lines in the beginning.
If you want to use textscan,
fid = fopen('xxx.csv');
C = textscan(fid, 'format', 'HeaderLines', 8);
var1 = C{1};
var2 = C{2};
Considering that it seems you seem to be importing heterogeneous data (different data types), I would recommend trying textscan. Depending on how your time vector is imported, you may need to use the datevec function as well.

  0 Comments

Sign in to comment.

More Answers (1)

Sean de Wolski
Sean de Wolski on 23 Mar 2011
My spanish is pretty poor but I'm going to guess you want to look at
doc csvread

Community Treasure Hunt

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

Start Hunting!

Translated by