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

4 次查看(过去 30 天)
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...

采纳的回答

Image Analyst
Image Analyst 2018-3-4
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 个评论
snr matlb
snr matlb 2018-3-4
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 2018-3-4
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;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by