¿Cómo puedo importar una señal que tengo guardada en formato csv?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
Anathea Pepperl
2011년 3월 23일
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
추가 답변 (1개)
Sean de Wolski
2011년 3월 23일
My spanish is pretty poor but I'm going to guess you want to look at
doc csvread
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!