Filter löschen
Filter löschen

PushButton in GUI and determine a variable with edit text and running another m file with this variable after clicking the button

4 Ansichten (letzte 30 Tage)
I wrote my program in the script section in Matlab. I want to make a user interface. there will be an edit text and button. After writing 20 in the edit text, it will goes to a variable in the Matlab my main programme and after clicking the button and my main program will run with variable that users writes by GUI edit text and give me the results in matrices? Is it possible to do it? I am not expert in Matlab and I tried another solutions as I found in the community.
Thank you in advance for your helping...

Akzeptierte Antwort

Image Analyst
Image Analyst am 4 Mär. 2018
Yes. You might want to start with this : MAGIC
Basically you get the edit field contents as a string, convert it to a double of 20 and then use it somehow in your code. So, in any callback, like the callback for a push button, do
userEntry = handles.editText1.String; % A string.
myNumber = str2double(userEntry); % Convert string to double number.
% More code goes here....
  4 Kommentare
snr matlb
snr matlb am 4 Mär. 2018
I get nothing after write save('a.mat'), it is not easy as Excel VBA macros. I want to make a user interface, write edittext, then push the button end I will get the results from my mainprogram.m :))
Image Analyst
Image Analyst am 4 Mär. 2018
You should get a file called "a.mat" in the current directory.
Then in your main program, which is a script for some reason, you can use load
s = load('a.mat');
s is a structure that has fields that are all the variables that existed in the workspace when you called save. For example to get myNumber and edittext, you can do
myNumber = s.myNumber;
edittext = s.edittext;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by