Saving a .mat file in csv format

1 visualización (últimos 30 días)
Sania Mirza
Sania Mirza el 6 de En. de 2022
Respondida: Image Analyst el 17 de En. de 2022
I have a .mat file and the data structure is as below.
Data =
struct with fields:
axis1: [25626600×1 double]
axis2: [25626600×1 double]
axis3: [25626600×1 double]
datenum: [25626600×1 double]
sample_rate: 30
serial_number: 'MOS2D10171145'
I want this .mat file to be save as a csv file.
I tried this code but it gives me this error.
csvwrite('FileName.csv', Data);
Undefined function 'real' for input arguments of type 'struct'.
Error in dlmwrite (line 189)
str = sprintf('%.*g%+.*gi',precn,real(m(i,j)),precn,imag(m(i,j)));
Error in csvwrite (line 42)
dlmwrite(filename, m, ',', r, c);
  3 comentarios
Rik
Rik el 6 de En. de 2022
How exactly would you like your csv file to be? Can you show an example with 10 elements (instead of the 25626600)?
Rik
Rik el 17 de En. de 2022
What exactly did you edit? And how does that answer our questions?

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 17 de En. de 2022
Try creating a double array from your structure:
data = [Data.axis1(:), Data.axis2(:), Data.axis3(:), Data.datenum(:)];
writematrix(data, fullFileName);

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by