Importing figure to MATLAB GUI using handles??

조회 수: 1 (최근 30일)
P
P 2013년 12월 17일
답변: nl2605 2013년 12월 18일
How can I literally take these figures and place them in the axes windows of my GUI?
I am not sure where to place handles in my user-defined code in the example below and I have 4 figures in total which look similar to this example. I want the 4 figures to be displayed in my GUI window and not in separate windows, so i've created 4 axes windows in the .fig file.
The code for this particular figure draws a grid of 66 black and white rectangles based on whether or not a value in MyVariable is a 1 or a 0. Black if MyVariable is a 1, White if MyVariable is 0. I have a file for my .fig GUI, one file to control the GUI and one with user-defined code that links to the GUI.
function test = MyScript(handles)
lots of code in between
% Initialize and clear plot window
figure(2); clf;
% Plot the west wall array panels depending on whether or not they are
% shaded or unshaded
for x = 1:11
for y = 1:6
if (MyVariable(x,y)) == 1
rectangle('position', [x-1, y-1, 1, 1] ,'EdgeColor', 'w', 'facecolor', 'k')
else if(MyVariablex,y) == 0)
rectangle('position', [x-1, y-1, 1, 1], 'facecolor', 'w')
end
end
end
end
title('West Wall Array',...
'FontWeight','bold')
axis off
The figure for the above code looks like this:
The function definition contains all of my script code for all 4 plots because I didn't partition my script into individual functions earlier on.
My GUI script code contains:
MyScript(handles);

답변 (1개)

nl2605
nl2605 2013년 12월 18일
When you know the handles of the axes in the GUI, you can plot the data in it.
Something like
plot(handles.axes_1,x,y);

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by