PushButton in GUI and determine a variable with edit text and running another m file with this variable after clicking the button
조회 수: 1 (최근 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...
댓글 수: 0
채택된 답변
Image Analyst
2018년 3월 4일
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
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!