script doesn't run from gui

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 ExchangeCreating, 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