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.)
댓글 수: 0
채택된 답변
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.
댓글 수: 0
추가 답변 (1개)
Leandro de Oliveira
2019년 9월 28일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!