Zooming a portion of figure in a figure

조회 수: 9 (최근 30일)
Marie Pettersen
Marie Pettersen 2019년 10월 25일
댓글: Marie Pettersen 2019년 10월 25일
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에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by