How to save a file with name saved in a variable ?

I need to save the output of my script in a .mat file which have as name the name I extract from the cell of an excel file.
The way I get the name is this:
[filename, filepath, ~] = uigetfile('*.xlsx');
[~,nnn] = xlsread([filepath, filename], i, 'A:A'); %import subject name
Name=[nnn(2,:)];
So the name is saved inside variable 'Name', and it changes every time inside the loop ( every time it takes it from a different excel work page).
filename=Name
save (filename , 'variables') doesn't work
and
filename=sprintf('%s',[Name{:}]) gives the error of 'cell' input.
How can I solve this?

2 commentaires

José-Luis
José-Luis le 1 Août 2017
Doesn't work how? What's the error message?
You must use
filename=Name{1} ;
And also give a proper extension...

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Commenté :

le 1 Août 2017

Community Treasure Hunt

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

Start Hunting!

Translated by