Plotting on Secondary y-axis and scaling

I'm trying to plot the following:
clear
clf
hold on
A = [0.1:0.1:1];
B = 100000./(A);
for i=1:length(A)
E(i) = 1842;
end
plotyy(A,E,A,B)
%Can clearly see both primary and secondary y-axis and x-axis without issue
A = [1:1:30];
B = 100000./(A);
for i=1:length(A)
E(i) = 1842/A(i);
end
plotyy(A,E,A,B)
After this point I can no longer clearly see both primary and secondary y-axis plots easily, and the x-axis overwrites itself any suggestions?

 Akzeptierte Antwort

Grzegorz Knor
Grzegorz Knor am 30 Jan. 2012

1 Stimme

Let's try it this way:
clear
clf
A1 = 0.1:0.1:1;
B1 = 100000./(A1);
E1 = nan(size(A1));
for i=1:length(A1)
E1(i) = 1842;
end
A2 = 1:1:30;
B2 = 100000./(A2);
E2 = nan(size(A1));
for i=1:length(A2)
E2(i) = 1842/A2(i);
end
plotyy([A1 A2],[E1 E2],[A1 A2],[B1 B2])

4 Kommentare

Shawn
Shawn am 30 Jan. 2012
Thank you Grzegorz for your answer it is greatly appreciated, I had one follow up question. Let say I have one more segment I want plotted I tried:
A3 = [30:1:100];
B3 = 100000./(A3);
E3 = nan(size(A1));
for i=1:length(A3)
E3(i) =61.4;
end
hold
plotyy([A2 A3],[E2 E3],[A2 A3],[B2 B3])
but this overwrites the x-axis again, and generated a new line instead of continuing from where the above code left off.
Grzegorz Knor
Grzegorz Knor am 30 Jan. 2012
Do not use hold on, just:
plotyy([A1 A2 A3],[E1 E2 E3],[A1 A2 A3],[B1 B2 B3])
Shawn
Shawn am 30 Jan. 2012
Thank you so much Grzegorz for your help.
Shawn
Shawn am 30 Jan. 2012
Follow up question: http://www.mathworks.com/matlabcentral/answers/27529-plotyy-x-axis-overwritting-with-two-plotyy-graphs-and-legend-issues

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by