How to request+input variable name+value then write to file?
Afficher commentaires plus anciens
I am trying to write a script that:
asks user for matrix name %like mat1
asks user for matrix value %like [20,30]
writes the matrix to a file
every time the script is run I want new data added to file, NOT overwriting what's already there.
-------
I use code like this to ask for variable value but don't know how to ask for variable name.
mat1 = input('Enter Name: \n','s');
-------
I use code like this to write to file but I don't know how to write a variable whose name I do not know prior to user putting it in. I also don't know how to make it so it doesn't over write information already present in file.
fid = fopen('locations.dat', 'w');
fprintf(fid,'%s\n',loc1M);
fclose(fid);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Import and Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!