I created a script called v1s, if I run that scrip from command windows, that script run excellent , but if I calle that script from a GUI (boton funtion) in the command windows appears the following:
Undefined variable "v1s" or class "v1s.m".
Error in Principal>pushbutton2_Callback (line 88)
v1s.m
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Principal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Principal('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I want know how call a script from a button funcion in a GUI
v1s script is:
v6(TbDate,vib1pp,TbDate(vib1pp>ppmax),vib1pp(vib1pp>ppmax),TbDate,vib1ap,TbDate(vib1ap>5),vib1ap(vib1ap>5),TbDate,vib1pd,TbDate(vib1pd>45),vib1pd(vib1pd>45),TbDate,vib1ad,TbDate(vib1ad>20),vib1ad(vib1ad>20),TbDate,vib1pf,TbDate(vib1pf>85),vib1pf(vib1pf>85),TbDate,vib1af,TbDate(vib1af<80),vib1af(vib1af<80))
if a pass all the value from GUI my graph is wrong.
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
global TbDate vib1pp vib1ap vib1pd vib1ad vib1pf vib1af ppmax
v6(TbDate,vib1pp,TbDate(vib1pp>ppmax),vib1pp(vib1pp>ppmax),TbDate,vib1ap,TbDate(vib1ap>5),vib1ap(vib1ap>5),TbDate,vib1pd,TbDate(vib1pd>45),vib1pd(vib1pd>45),TbDate,vib1ad,TbDate(vib1ad>20),vib1ad(vib1ad>20),TbDate,vib1pf,TbDate(vib1pf>85),vib1pf(vib1pf>85),TbDate,vib1af,TbDate(vib1af<80),vib1af(vib1af<80))

답변 (1개)

Adam
Adam 2015년 3월 4일
편집: Adam 2015년 3월 4일

0 개 추천

You should call the script my its name without '.m' attached i.e. just
v1s
not
v1s.m
The script will run in the scope of the pushbutton callback, whether that is what you want or not I don't know.

댓글 수: 4

Alejandro Franco
Alejandro Franco 2015년 3월 4일
I put just v1s but in the graph nothing appears, it look like , dont see de var in workspace do you have any idea? thanks!!!
Adam
Adam 2015년 3월 4일
I can't see any plotting functions in your script, but any plotting instructions there are should refer to explicit axes to ensure your plot is in the right place.
As for the variables, as i mentioned, the script is run within the scope of your pushbutton callback therefore the variables are in that scope and go out of scope when the callback ends. They never appear in the base workspace.
I have never had requirement personally to have a GUI front end to something, but have the variables appear in the base workspace, I always work with them under the GUI.
I think you can use the assignin function from your pushbutton callback if you really want the variables in your base workspace.
Ankit Singh
Ankit Singh 2016년 5월 8일
but when we save them in work space
Image Analyst
Image Analyst 2016년 5월 8일
편집: Image Analyst 2016년 5월 8일
Ankit, that doesn't make sense - finish your sentence or expand on what you're saying.

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2015년 3월 4일

편집:

2016년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by