How to read and save different variables in a matfile to another mat file

2 vues (au cours des 30 derniers jours)
How to read two specific variables from a .mat file having different variables and save it to another .mat file without changing the variable name.

Réponse acceptée

Stephen23
Stephen23 le 21 Sep 2018
Modifié(e) : Stephen23 le 21 Sep 2018
S = load('file1.mat','var1','var2');
save('file2.mat','-struct','S')
OR
S = load('file1.mat');
save('file2.mat','-struct','S','var1','var2')
  5 commentaires
Stephen23
Stephen23 le 24 Sep 2018
@sachin k p: if the names are different then you could try the '-append' option, like this:
S = load('file1.mat','var1','var2');
save('file2.mat','-struct','S','-append')
sachin k p
sachin k p le 25 Sep 2018
Thank you Stephen

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by