[原创]急~~明天就要交了,能看看我编的程序吗?一个功能实现不了!
你可运行我的main.m文件,然后点击“绘图”菜单会弹出一个窗口(图例 http://pconline.tengyi.cn/tp2.jpg),然后我要实现一个功能:在各个TEXT文本框中输入公式(文本框中有),当点击“绘图”后会在主窗口中绘出图形。回复:(usin)[原创]急~~明天就要交了,能看看我编的...
没看懂你的意思 大家如果不懂我的意思可先下载我的程序文件 <a href="http://pconline.tengyi.cn/cx.rar" target="_blank" ><FONT color=#003366>http://pconline.tengyi.cn/cx.rar</FONT></A> 在MATLAB中打开main.m文件,运行试一试!<BR><BR>帮帮我,真的很急啊~~~ function multiplePlot()<BR>% 可编辑框、弹出框、列表框、按键示例<BR>% 目的:制作能绘制任意图形的交互界面.包括:可编辑文本框、弹出框、列表框.<BR>% 实现关键为如何使得编辑框允许输入多行指令<BR>figure;<BR>global hEdit hPop hList<BR>set(gcf,'menubar','none');<BR>set(gcf,'unit','normalized','position',[.1,.4,.85,.35]);<BR>set(gcf,'defaultuicontrolunits','normalized');<BR>set(gcf,'defaultuicontrolfontsize',11);<BR>set(gcf,'defaultuicontrolfontname','隶书');<BR>set(gcf,'defaultuicontrolhorizontal','left');<BR>str='通过多行指令绘图的交互界面';<BR>set(gcf,'name',str,'numbertitle','off');<BR>hAxes=axes('position',[.05,.15,.45,.7],'visible','off');<BR>uicontrol(gcf,'style','text',...<BR> 'position',[.52,.87,.26,.1],...<BR> 'string','绘图指令输入框');<BR>hEdit=uicontrol(gcf,'style','edit',...<BR> 'position',[.52,.05,.26,.8],...<BR> 'max',2);<BR>hPop=uicontrol(gcf,'style','popup',...<BR> 'position',[.8,.73,.18,.12],...<BR> 'string','spring|summer|autumn|winter');<BR>hList=uicontrol(gcf,'style','list',...<BR> 'position',[.8,.23,.18,.37],...<BR> 'string','Grid on|Box on|Hidden off|Axis off',...<BR> 'max',2);<BR>hPush=uicontrol(gcf,'style','push',...<BR> 'position',[.8,.05,.18,.15],'string','Apply');<BR>% set(hEdit,'callback','calledit(hEdit,hPop,hList)');<BR>% set(hPop,'callback','calledit(hEdit,hPop,hList)');<BR>% set(hPush,'callback','calledit(hEdit,hPop,hList)');<BR>set(hEdit,'callback','calledit');<BR>set(hPop,'callback','calledit');<BR>set(hPush,'callback','calledit');<BR>=============================================================<BR>%另外写一个函数calledit做回调<BR>function calledit<BR>global hEdit hPop hList<BR>ct=get(hEdit,'string'); % 获得输入的字符串函数<BR>vPop=get(hPop,'value'); % 获得选项的位置标识<BR>vList=get(hList,'value'); % 获得选项位置向量<BR>if ~isempty(ct) % 当可编辑框为非空时执行如下指令<BR> eval(ct');% 运行从编辑文本框送来的指令<BR> popstr={'spring','summer','autumn','winter'}; % 弹出色图框矩阵<BR> liststr={'grid on','box on','hidden off','axis off'};<BR> invstr={'grid off','box off','hidden on','axis on'};<BR> colormap(eval(popstr{vPop}));<BR> vv=zeros(1,4);<BR> vv(vList)=1;<BR> for k=1:4<BR> if vv(k);<BR> eval(liststr{k});<BR> else<BR> eval(invstr{k});<BR> end<BR> end<BR>end
页:
[1]