Figures into subplots

1 次查看(过去 30 天)
Is there a way to take a figure (*.fig file, or just any open figure) and insert it completely into a subplot? (I think I can do it by copying each handle of the figure, but I'm looking for an easier way.)

采纳的回答

Daniel Shub
Daniel Shub 2012-3-28
Copying into a subplot would be difficult. Technically subplots are just an axis, but figures can have children that cannot be parented by an axis. A better choice might be to make a gird of uipanels. Any object that can be a child of a figure, can also be parented by a uipanel. You can then use the findobj and copyobj functions to copy your figure to a uipanel. Note that a uipanel grid will not behave identically to axes made with subplot.

更多回答(1 个)

Leandro de Oliveira
Try something like this (the for loop):
clc; clear all; close all;
%-------------------------------------------------------------------------%
s = tf('s');
%-------------------------------------------------------------------------%
G = (s+40)/((s^2)+(1.2*s)+4);
%-------------------------------------------------------------------------%
lw = 2;
for i = 1:2
subplot(2,1,i)
if i == 1
h = figure(1);
[mag, fase, w] = bode(G);
hObj = semilogx(w, 20*log10(squeeze(mag)), 'linewidth', lw);
[max_val, index] = max(mag);
cursorMode = datacursormode(h);
hDatatip = cursorMode.createDatatip(hObj);
pos = [w(index) 20*log10(mag(index))];
set(get(hDatatip, 'DataCursor'), 'DataIndex', index, 'TargetPoint', pos);
set(hDatatip, 'Position', pos);
updateDataCursors(cursorMode);
xlabel('Frequência [rad/s]')
ylabel('Magnitude [dB]')
grid on;
end
if i == 2
h = figure(1);
semilogx(w, squeeze(fase), 'linewidth', lw);
xlabel('Frequência [rad/s]')
ylabel('Fase [graus]')
grid on;
end
end

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by