Create workspace file automatically.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Let's say I have:
a = {'one' 'two' 'three'};
b = [1 2 3];
I want each word create a file in workspace automatically and equal to number. Like:
one=1; two=2; three=3;
0 commentaires
Réponse acceptée
Brett Shoelson
le 10 Fév 2011
I think you mean "variable," not "file." Right?
for ii = 1:numel(a)
eval(sprintf('%s = %d',a{ii},b(ii)));
end
Cheers,
Brett
2 commentaires
Plus de réponses (2)
Walter Roberson
le 10 Fév 2011
This is generally considered poor programming and hard to maintain. Please see the FAQ answer on this topic for alternatives.
0 commentaires
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!