为了账号安全,请及时绑定邮箱和手机立即绑定

??? Error while evaluating uicontrol Callback

??? Error while evaluating uicontrol Callback

长风秋雁 2023-02-11 22:18:43
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));']);


查看完整回答
反对 回复 2023-02-15
  • 1 回答
  • 0 关注
  • 136 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信