【问题标题】:Plotting image and points on Matlab GUI via update function通过更新功能在 Matlab GUI 上绘制图像和点
【发布时间】:2015-08-27 20:29:52
【问题描述】:

请原谅我的菜鸟,但这是我的第一篇文章。

我在 matlab 中生成了这个 gui,我想通过更新函数在其中一个轴上绘制图像。

我知道在 Matlab 中你可以做类似的事情

图片(图片) 坚持,稍等 情节(x1,z1) 等一下

但是如何使用 gui 来做到这一点?

这里是更新函数的一部分

%get a handle to the GUI's 'current state' window
deflectionx = findobj('Tag','deflectionx_display');
deflectiony = findobj('Tag','deflectiony_display');
depth = findobj('Tag','depth_display');
Graph = findobj('Tag','Graphical_display');
UltraS = findobj('Tag','UltraS_image');
%update the gui
set(deflectionx,'String',x_def);
set(deflectiony,'String',y_def);
set(depth,'String',insert_depth);


%% above works fine. below does not

%i want this to plot those points on top of the image in the large graph panel of the gui
plot(Graph,img1)
hold on
plot(Graph,x1,z1);
hold off

%this should plot the second image on the UltraS panel
plot(UltraS,img2)

请提前致谢!

【问题讨论】:

  • 怎么不行??什么都没有显示?显示的内容有误?
  • 底部不起作用,顶部,提取从函数接收的数据并使用标签“deflectionx”、“deflectiony”、“深度”更新 gui。我认为这是因为我只是更改了字符串的值。Graph 和 UltraS 变量引用了我的 gui 的两个图。没有显示任何内容。

标签: image matlab user-interface graph plot


【解决方案1】:

所以我想我必须在 gui 的打开函数中将 GUI 的句柄写入工作区

% --- Executes just before VR_gui is made visible.
function VR_gui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to VR_gui (see VARARGIN)

% Choose default command line output for VR_gui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

%setting axis
needle_plot = handles.Graphical_display;
US_plot = handles.US_image;

%write handle to workspace
assignin ('base','needle_plot',needle_plot);
assignin ('base','US_plot',US_plot);

然后从更新函数中读取工作区变量

needle_plot = evalin('base','needle_plot');
US_plot = evalin('base','US_plot');

axes(US_plot);
image(img2);

axes(needle_plot);
plot(x1,z1,'r--o');

【讨论】:

    猜你喜欢
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多