
matlab问题求助!!
hf=figure('Position',[200 200 600 400],...'Name','Uicontrol1',...'NumberTitle','off');
ha=axes('Position',[0.4 0.1 0.5 0.7],...'Box','on');
hbSin=uicontrol(hf,...'style','pushbotton',...'Position',[50 140 100 30],...'String','Plot sin(x)',...'CallBack',...['subplot(ha);'...'x=0:0.1:4*pi;'...'plot(x,sin(x))'...'axis([0 4*pi -1 1]);'...'grid on;'...'xlable("x");'...'ylable("y=sin(x)");'...]);
调试后出现 ??? ha=axes('Position',[0.4 0.1 0.5 0.7],...'Box','on');
|
Error: The expression to the left of the equals sign is not a valid target for an assignment. 展开
你的代码里有几个错误,我帮你纠正了:
clear;clc
hf=figure('Position',[200 200 600 400],...
'Name','Uicontrol1',...
'NumberTitle','off');
ha=axes('Position',[0.4 0.1 0.5 0.7],...
'Box','on');
hbSin=uicontrol(hf,...
'Style','pushbutton',...
'Position',[50 140 100 30],...
'String','Plot sin(x)',...
'CallBack',...
['subplot(ha);'...
'x=0:0.1:4*pi;'...
'plot(x,sin(x));'...
'axis([0 4*pi -1 1]);'...
'grid on;'...
'xlabel(''x'');'...
'ylabel(''y=sin(x)'');'...
]);
主要错误有:
1 注意断行,每个“...”之后都要重启一行;
2 pushbutton拼写错误
3 xlabel拼写错误;ylabel拼写错误;
4 xlabel和ylabel里面不是双引号,而是四组两个单引号。
执行结果