Filter löschen
Filter löschen

Load data into GUI editable fields from txt

3 Ansichten (letzte 30 Tage)
Pelajar UM
Pelajar UM am 10 Sep. 2021
Kommentiert: Walter Roberson am 10 Sep. 2021
I have an application with several inputs.
Currently, I input the data manually in the GUI. I want to add a push button and load a txt file that contains numbers, text, etc that goes into these fields.
Examples of the fields and the data:
app.REditField.Value = PEI
app.DEditField.Value = 1.33
app.Slider.Value = 20
% pick one
app.EButton = 0
app.SButton = 0
app.HButton = 1
I saw some examples with "eval" and "readtable" but they are not variables... Here’s what I have so far (I know it’s not much):
% Button pushed function: LoadDataButton
function LoadDataButtonPushed(app, event)
[filename] = uigetfile ({'*txt'});
end
  9 Kommentare
Pelajar UM
Pelajar UM am 10 Sep. 2021
Bearbeitet: Pelajar UM am 10 Sep. 2021
It makes sense. I changed the extension to .m and it works perfectly now. Thank you so much.
By the way, is there a way to encrypt this .m input file so that you can only open it with the app?
Update: I converted to .p file (obfusicated) and it still works in the same way as .m. (I know p-code is not the same thing as encryption).
Walter Roberson
Walter Roberson am 10 Sep. 2021
If the extension is already .m or .p then
function LoadDataButtonPushed(app, event)
[filename, folder] = uigetfile({'*.m', '*.p'});
if ~ischar(filename); return; end %user cancel
filename = fullfile(folder, filename);
run(filename);
end

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by