PushButton in GUI and determine a variable with edit text and running another m file with this variable after clicking the button
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
snr matlb
el 4 de Mzo. de 2018
Comentada: Image Analyst
el 4 de Mzo. de 2018
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...
0 comentarios
Respuesta aceptada
Image Analyst
el 4 de Mzo. de 2018
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 comentarios
Image Analyst
el 4 de Mzo. de 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;
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!