Figures into subplots
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
kfir
le 28 Mar 2012
Réponse apportée : Leandro de Oliveira
le 28 Sep 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 commentaires
Réponse acceptée
Daniel Shub
le 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 commentaires
Plus de réponses (1)
Leandro de Oliveira
le 28 Sep 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 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!