2015-06-11 83 views
-1

請原諒我的noobness,但這是我的第一篇文章。通過更新函數在Matlab GUI上繪製圖像和點

我在matlab中生成了這個gui,我想從一個更新函數的軸上繪製圖像。

我知道在Matlab你可以做這樣的事情

圖像(IMG) 保持在 圖(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) 

請和謝謝提前的一段!

+0

讀取工作區變量怎麼來這是行不通的??什麼都沒有顯示?你顯示錯誤的東西? –

+0

底部不工作,頂部,拉動從函數收到的數據,並更新gui標籤「撓曲x」,「撓曲」,「深度。我認爲這是因爲我只是改變Graph和UltraS變量指向我的gui的兩個圖,沒有任何顯示。 –

回答

0

所以想通我不得不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');