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...

채택된 답변

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에서 Word games에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by