![]() |
在MATLAB中更新GUI轴
我正在为自己创建的程序制作GUI,在该程序中我需要能够更改沿梁的载荷位置。我已经正确设置了轴和滑块,但是我不确定如何更新轴,因为在互联网上找不到任何显示如何执行此操作的示例。
目前,当我移动负载时,位置会正确更新,但旧位置也会保留在屏幕上,这很烦人。 谁能推荐一些很好的例子来说明如何做到这一点,或者有人建议如何刷新轴吗? 这是滑块回调(我没有包括create_fcn函数)。另外,在代码中有很多注释,因为我使用了Guide函数制作了GUI。 请注意,滑块的输入是光束总长的比例(以十进制表示)。 function PointLoadxx1posslider_Callback(hObject, eventdata, handles) % hObject handle to PointLoadxx1posslider (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider PLxx1pos = get(handles.PointLoadxx1posslider,'value'); set(handles.PLxx1posedit, 'String', num2str(PLxx1pos)); l = 3000; % This is the Length of the beam zpl1 = get(handles.PointLoadxx1posslider,'value')*l; % Multiplies the position decimal by the overall length LoadPlotter(hObject,zpl1,handles) % Sends the command to the plot plot function guidata(hObject,handles); function LoadPlotter(hObject,zpl1,handles) % The following draws the beam supports as lines SH = l/20; %Height of supports line([0 l], [SH/2 SH/2]) line([-SH/2 SH/2], [0 0]) line([-SH/2 0], [0 SH/2]) line([0 SH/2], [SH/2 0]) line([l-SH/2 l+SH/2], [0 0]) line([l-SH/2 l], [0 SH/2]) line([l l+SH/2], [SH/2 0]) xlim([ -100 l+200]) ylim([-l/2 l/2]) %Draw Load position % zpl1 = get(handles.PointLoadxx1posslider,'value')*l; % zpl1 = 0.5*l; zpl2 = 0.2*l; PL1 = 50; %This is the value of the point load applied to the beam, which will be an input from another slider PL1Draw = line([zpl1 zpl1],[SH/2 PL1*10]); % refresh(handles.axes1); guidata(hObject,handles); 显然,我想保留其他线条,但是随着滑块的移动更改PL1Draw。请您解释一下我应该为此做些什么? 提前谢谢了。 詹姆士 [B]回答:[/B] 与实际问题无关,但与项目有关: [URL]http://www.mathworks.com/matlabcentral/fileexchange/2170[/URL] 本书仍可在Amazon上使用,它可以为您节省很多有关Mechanics of Materials的编码。我大约在12年前作为本科生写的,但是我认为MATLAB代码应该仍然可以运行。 [url=https://stackoverflow.com/questions/2508006]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 05:02。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.