Zooming a portion of figure in a figure

9 次查看(过去 30 天)
Hi, i want to zoom in on a portion of this figure. It is a plot of eigenvalues, and I want to show a zoomed figure of the eigenvalues close to real axis equal zero. As you can see I have tried my best at the end, but it doesn't work. Can anyone help?
close all
L = 0.01;
R = 0.1;
K_i = 800;
K_p = [0.8, 1.2, 2, 4, 10, 40, 100];
figure;
for i=1:length(K_p)
A = [0 -K_i ; 1/L -(R+K_p(i))/L];
z = eig(A);
a = real(z);
b = imag(z);
txt = ['Kp = ', num2str(K_p(i))];
plot(a, b, 'o', 'DisplayName',txt)
hold on
legendnames(i) = K_p(i);
end
hold off
grid on
legend('Location','northwest')
legend show
xlabel('Real axis'),ylabel('Imaginary axis')
xlim([-10500 100])
ylim([-300 300])
axes('position', [0.2 0.2 0.25 0.25])
box on
your_index = -1000 < a & 100 > a;
plot(a(your_index), b(your_index));
axis tight

采纳的回答

Daniel M
Daniel M 2019-10-25
编辑:Daniel M 2019-10-25
I just made some minor adjustments
close all
L = 0.01;
R = 0.1;
K_i = 800;
K_p = [0.8, 1.2, 2, 4, 10, 40, 100];
figure('Position',[52 237 890 659]);
for i=1:length(K_p)
A = [0 -K_i ; 1/L -(R+K_p(i))/L];
z = eig(A);
a = real(z);
b = imag(z);
txt = ['Kp = ', num2str(K_p(i))];
plot(a, b, 'o', 'DisplayName',txt)
hold on
legendnames(i) = K_p(i);
end
g = get(gca);
pt = 7;
colorOfPoint = g.ColorOrder(pt,:);
% this get the color of the point "pt"
hold off
grid on
legend('Location','northwest')
legend show
xlabel('Real axis'),ylabel('Imaginary axis')
xlim([-10500 100])
ylim([-300 300])
axes('position', [0.2 0.2 0.25 0.25])
box on
your_index = -1000 < a & 100 > a;
plot(a(your_index), b(your_index),'o','MarkerSize',10,'Color',colorOfPoint);
axis tight
grid on
ann1 = annotation('textbox', 'Units','pixels',...
'Position',[198 109 203 76], ...
'String', 'Kp = 100', ...
'EdgeColor', 'none', ...
'FontSize', 12, ...
'FontName', 'Helvetica');
  3 个评论
Daniel M
Daniel M 2019-10-25
Yes it's possible, just make an array that contains all those points, and plot them. Although, they are kind of spread apart, I don't really see how the inset picture will be better than your main figure.
Marie Pettersen
Marie Pettersen 2019-10-25
That's true. Again, thank you very much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by