??? Error while evaluating uicontrol Callback

h_main=figure('name','a demo of','menubar','none','numbertitle','off','position',[100,100,300,100]);
h_edit=uicontrol('style','edit','backgroundcolor',[1,1,1],'position',[20,20,50,20],...
'tag','myedit','string','1','horizontal','left');
h_but1=uicontrol('style','pushbutton','position',[20,50,50,20],'string','INC',...
'callback',['h=findobj(gcf,"tag","myedit");','v=eval(get(h,"string"));','set(h,"string",int2str(v+1));']);
??? Error using ==> h=findobj(gcf,"tag","myedit");v=eval(get(h,"string"));set(h,"string",int2str(v+1));
Error: The input character is not valid in MATLAB statements or expressions.

长风秋雁
浏览 137回答 1
1回答

芜湖不芜

回调函数中的字符串应该用两个单引号('')括起来,而不是用双引号(")。一共有8处需要替换,即:h_but1=uicontrol('style','pushbutton','position',[20,50,50,20],'string','INC',...'callback',['h=findobj(gcf,''tag'',''myedit'');','v=eval(get(h,''string''));','set(h,''string'',int2str(v+1));']);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

数据结构