Figures into subplots
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
kfir
il 28 Mar 2012
Risposto: Leandro de Oliveira
il 28 Set 2019
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 Commenti
Risposta accettata
Daniel Shub
il 28 Mar 2012
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 Commenti
Più risposte (1)
Leandro de Oliveira
il 28 Set 2019
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 Commenti
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!