How to use the data from a .mat file to make a graphic?

1 visualización (últimos 30 días)
Ariane
Ariane el 31 de En. de 2023
Respondida: Star Strider el 31 de En. de 2023
I need to use the data from a .mat file to make a graphic. Matlab has to use the first columns as the distance (x) and the second one as the time (t). I know how to make a graphic with a .txt file but it doesn't work with the .mat file. This is what I wrote: load 'data.mat'
x=data.mat(:,1) (I want to tell Matlab that the first columns is the variable x)
t=data.mat(:,2) (I want to tell Matlab that the second columns is the variable t)
This is what appear on the command window:
Unable to resolve the name 'data.mat'.
Error in question4 (line 2)
x=data.mat(:,1)
I wrote the same thing with a .txt file and it worked.

Respuesta aceptada

Star Strider
Star Strider el 31 de En. de 2023
Use the load function to ‘read’ the .mat file. (I always load into a variable as a structure of the .mat file contents so that I understand what is in the file and can choose what to import into my workspace.) See the documentation for details.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by