My saving function works before compiling it as a standalone software using app designer

The save function works and save the data from the table to .mat folder when i run in matlab. But after i compile it into a standalone software, it does not work the same way. It does not save no more and when i press the save button, it acts as error.
function startupFcn(app)
app.anam=load("Anam.mat","mergefilesanam");
assignin("base",'anam',app.anam);
app.data=evalin("base",'anam.mergefilesanam');
app.UITable_2.Data=app.data;
app.UITable.Data=app.data;
app.UITable_2.ColumnName=app.data.Properties.VariableNames;
app.UITable.ColumnName=app.data.Properties.VariableNames;
app.numRows=size(app.data,1);
end
function savebuttonImageClicked(app, event)
mergefilesanam=(app.UITable.Data);
save("Anam.mat","mergefilesanam");
anam=load("Anam.mat","mergefilesanam");
assignin("base",'anam',anam);
end

 採用された回答

Image Analyst
Image Analyst 2021 年 12 月 30 日
Specify the full file name -- folder plus base file name plus extension:
folder = 'd:\mydata'; % Wherever you want.
fullFileName = fullfile(folder, 'Anam.mat');
save(fullFileName,"mergefilesanam");

6 件のコメント

Aung Moe Zaw
Aung Moe Zaw 2021 年 12 月 30 日
and if i want to call the file back and display it in the table should is use load(fullfilename)?
aman = load(fullFileName);
assignin("base", 'anam', anam);
Remember though that that will be a struct with one field for every variable that was saved in the file.
You should probably not be working with the base workspace in App Designer. Create an app property instead.
Aung Moe Zaw
Aung Moe Zaw 2021 年 12 月 30 日
should be like this?
app.aman = load(fullFileName);
assignin("base", 'anam', app.anam);
Aung Moe Zaw
Aung Moe Zaw 2021 年 12 月 30 日
property(Access=Public)
anam;
end
function startupFcn(app)
folder = 'C:\Program Files\Citanix\machineinterface'; % Wherever you want.
fullFileName = fullfile(folder, 'Anam.mat');
app.anam=load(fullFileName,"mergefilesanam");
assignin("base",'anam',app.anam);
app.data=evalin("base",'anam.mergefilesanam');
app.UITable.Data=app.data;
app.UITable.ColumnName=app.data.Properties.VariableNames;
end
function savebuttonImageClicked(app, event)
folder = 'C:\Program Files\Citanix\machineinterface'; % Wherever you want.
fullFileName = fullfile(folder, 'Anam.mat');
mergefilesanam=(app.UITable.Data);
save(fullFileName,"mergefilesanam");
app.anam=load(fullFileName,"mergefilesanam");
assignin("base",'anam',app.anam);
end
Aung Moe Zaw
Aung Moe Zaw 2021 年 12 月 30 日
should i try like this?
Aung Moe Zaw
Aung Moe Zaw 2021 年 12 月 30 日
Thank you very much it works now

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 12 月 30 日

0 投票

Did your app cd() to somewhere? If not, then what directory do you think you are in at the time you save() ?

1 件のコメント

Aung Moe Zaw
Aung Moe Zaw 2021 年 12 月 30 日
I am not sure about that....all the files that i use are in the same folder when i call/load and save when using matlab...do you have a sample coding i could refer to?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by