How can I save a string as a filename and only include specific variables
Ältere Kommentare anzeigen
Hi, I'm trying to generate a .dat file, with a filename specified by the user, only including one variable from the file, an array titled A. I've managed to either save the .dat with the user-specified filename, or to save the .dat with a given filename and only including the array, but not the two at the same time.
To get a variable filename, I followed the advice here: http://www.mathworks.co.uk/matlabcentral/answers/42823 and typed
name = 'Enter filename: ';
file = input(name,'s');
save (file);
That generates a file with the name input (e.g. myfile.dat), but the contents are garbled.
To get a .dat file with the contents of A, I typed
save -ascii MatrixA.dat A;
That gives a .dat containing the values of A as required, but doesn't let the user change the filename. I've tried combining the two segments in various ways, but haven't managed to find any that work yet. I'd really appreciate any guidance!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!