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.
1 回答
芜湖不芜
TA贡献1796条经验 获得超7个赞
回调函数中的字符串应该用两个单引号('')括起来,而不是用双引号(")。
一共有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));']);
- 1 回答
- 0 关注
- 136 浏览
添加回答
举报
0/150
提交
取消