App designer - uiputfile is saving the file to the wrong path

4 ビュー (過去 30 日間)
Teshan Rezel
Teshan Rezel 2021 年 4 月 27 日
回答済み: Adam Danz 2021 年 4 月 27 日
Hi folks,
I have the following code to save a table as an excel file. The problem is, the file is always saved to the default matlab path and not the user selected path.
Any ideas why this might be please?
Thanks!
FileName = uiputfile('*.xls','Save as');
data = app.CokeTable.Data;
columnName = {'Morphology','Counts', 'Percentages'};
rowName = {'Incipient','Circular', 'Lenticular','Ribbon','Isotropic','Filler','Resin','Total'}';
writecell(rowName, FileName, 'Range', 'A2:A9');
writecell(columnName, FileName, 'Range', 'A1:c1');
writematrix(data, FileName, "Range", 'B2:C9');

採用された回答

Adam Danz
Adam Danz 2021 年 4 月 27 日
Always go directly to the documentation to understand the expected behavior of a function.
uiputfile returns up to 3 ouputs. The first is the filename and the second is the selected path.
Use [file,path] = uiputfile to store both the filename and path.
Then use fullfilepath=fullfile(path,file) to generate the full path to the file including the extension.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by