Azzera filtri
Azzera filtri

Save in App designer text area value not as .txt, .dat, or .csv file - Matlab

3 visualizzazioni (ultimi 30 giorni)
I have tried to save an App designer text area value not as .txt, .dat, or .csv file (used for delimited text files) but rather as an .xyz format (mainly it is just a text file with different extension name).
I used this code line:
writecell(app.XYZfilecontentTextArea.Value, 'E:\', 'QuoteStrings',false);
and I get this Error using writecell Unrecognized file extension '.xyz'. Use the 'FileType' parameter to specify the file type.
Any idea how can I save my data? It works fine if I wish to save it as txt.

Risposte (2)

Voss il 16 Ott 2023
writecell(app.XYZfilecontentTextArea.Value, 'E:\', 'QuoteStrings',false, 'FileType','text');

dpb il 16 Ott 2023
Modificato: dpb il 17 Ott 2023
Follow the instructions, Luke! <VBG> See rest of named-value pairs at <writecell>
writecell(app.XYZfilecontentTextArea.Value, 'E:\', 'QuoteStrings',false,'FileType','text');
Although from just a practical standpoint, if it is a text file, then .txt would seem a much more logical extension to pick unless there really is some other meaning that is assigned to xyz that has bearing on the file content/application.
It doesn't really matter what a file is named other than one of some convenience with some of the OS conventions like file association with applications and the need for special handling like the above when go against convention in MATLAB, other than there are some applications like Excel that simply won't allow such shenanigans. I've not checked recently whether it would let you import such a file or not; I know it won't open a .xls_ file of any variety unless the extension matches what is expected for the format; that's how it chooses the engine with which to try to open it.
" I've not checked recently whether it would let you import such a file or not;..."
I just did; it will let you open a csv file not named as such, but you then have to go thru the import wizard by hand to set the delimiter to match in order for Excel to import the fields into cells--by default it picks tab, not comma and you get every record in a single cell. All in all, it just seems like abadidea™ to not use conventional naming unless there's a very specific reason otherwise; looks a though will likely just cause trouble down the line.


Scopri di più su Data Import and Export in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by