Load a variable from base workspace into a edittext field

I have a a function called DataCollector.m The function opens the file explorer using
[FileName,PathName] = uigetfile('*.lcm','Select the MATLAB code file');
Which is in the DataCollector.m file.
So i would like to take the parameter FileName and display it in a edit text field. So i have written
app.EditField.Value = FileName;
Which does not work. How do i solve this?

2 件のコメント

Jan
Jan 2018 年 2 月 16 日
Please explain "does not work" with any details. How could the readers suggest a solution, if they do not know, what's going wrong?
adnan Hossain
adnan Hossain 2018 年 2 月 16 日
Well the text field does not change text. I would like to display the FileName text there.

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

 採用された回答

adnan Hossain
adnan Hossain 2018 年 2 月 16 日

0 投票

I solved it by making the variable FileName global in the .m file.

その他の回答 (1 件)

Stephen23
Stephen23 2018 年 2 月 16 日

0 投票

Define the function so that FileName is an input argument:
function DataCollector(FileName)
...
app.EditField.Value = FileName;
...
end
and then simply call it with whatever value you want:
DataCollector('MyFile')

1 件のコメント

adnan Hossain
adnan Hossain 2018 年 2 月 16 日
Could you please elaborate this a bit more? Should i use this code in the app designer? the DataCollector('MyFile') part, where should i post this?

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

カテゴリ

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

タグ

質問済み:

2018 年 2 月 16 日

編集済み:

2018 年 2 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by