Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
 
 
主题工具 显示模式
旧 2019-12-10, 20:30   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 在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。请您解释一下我应该为此做些什么?

提前谢谢了。

詹姆士



回答:

与实际问题无关,但与项目有关:

http://www.mathworks.com/matlabcentr...eexchange/2170

本书仍可在Amazon上使用,它可以为您节省很多有关Mechanics of Materials的编码。我大约在12年前作为本科生写的,但是我认为MATLAB代码应该仍然可以运行。



更多&回答...
poster 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 05:13


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.