How to pass data from a MatLab GUI to an .m file?

조회 수: 9 (최근 30일)
Riccardo Celin
Riccardo Celin 2020년 2월 11일
답변: Andy 2020년 2월 11일
Goodmorning everybody. Can you please help me with this problem?
I'm very new to MatLab's app designer and i was asking how i could share a variable in a GUI with a .m file.
In particulare, in the GUI, i have a numeric field and i want to share that value, once it has been insert, with a variable in an .m file; is it possible?
For semplicity, i'll post only the first code lines of th .m file:
clc
close all
clear all
app=Schedule; %Opening the GUI
tmp=app.Days; %BUT with this line i'll obviously get the value '0'
Here the code of the GUI:
properties (Access = public)
Days=0 %property name I want to share with .m file
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: DaysEditField
function DaysEditFieldValueChanged(app, event)
value = app.DaysEditField.Value;
app.Days=value;
%once the numeric fild has been chenged i would have it to be sent to a variable in the .m file (HOW?)
end
end
Thank you all for your time!
RC
  댓글 수: 2
Andy
Andy 2020년 2월 11일
If you want an m file to ask for an input why not use inputdlg ?
If you want the Gui to be the one that the user works with, run the gui then have that call the m-file.
yourmfile(value);
Rik
Rik 2020년 2월 11일
@Andy please post your answer in the answer section.

댓글을 달려면 로그인하십시오.

채택된 답변

Andy
Andy 2020년 2월 11일
If you want an m file to ask for an input why not use inputdlg ?
If you want the GUI to be the one that the user works with, run the gui then have that call the m-file.
yourmfile(value);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by