How can I use .mat file as new variable?

1 visualización (últimos 30 días)
Faezeh Manesh
Faezeh Manesh el 3 de Jul. de 2019
Respondida: Faezeh Manesh el 4 de Jul. de 2019
Hello!
I have saved some data from excell to matlab as a .mat file. Now I want to load and use them in matlab. For example, my data are saved in a file called 'DCS_data.mat' which includes 1996*2 data. I want to save the first column in a variable called T and the second column in a variable called heat. But I don't know how to do that. Could you pleae help me with this problem.
Regards,
Faezeh

Respuesta aceptada

Star Strider
Star Strider el 3 de Jul. de 2019
Another option:
S = load('DCS_data.mat');
C = struct2cell(S);
T = C{1}(:,1);
heat = C{1}(:,2);
save('DCS_data(2).mat', 'T', 'heat');
This assumes that the first (perhaps only) matrix in ‘DCS_data.mat’ is the one you want to work with. (It would help to have ‘DCS_data.mat’ to experiment with.) Name your new .mat file whatever you want. I called it ‘DCS_data(2).mat’.

Más respuestas (2)

KALYAN ACHARJYA
KALYAN ACHARJYA el 3 de Jul. de 2019
new_var=load('DCS_data.mat')
  1 comentario
Matt J
Matt J el 3 de Jul. de 2019
Editada: Matt J el 3 de Jul. de 2019
and then
T=new_var.whatever(:,1);
heat=new_var.whatever(:,2);

Iniciar sesión para comentar.


Faezeh Manesh
Faezeh Manesh el 4 de Jul. de 2019
Thank you very much!

Categorías

Más información sobre Use COM Objects in MATLAB 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