Filter löschen
Filter löschen

Plotting two plots with 2 different y axes

1 Ansicht (letzte 30 Tage)
KKR
KKR am 7 Apr. 2012
Hi Everyone,
Hope everyone is doing great and having a great easter break.
I have minor issue regarding plotting two plots with two y-axes. I tried plotyy but i didnt work as I kept getting error message that vectors should be of same length.
spot_y = (3000:500:13000)';
delta_y = (-1:0.1:1)';
plotyy(spot(:,1),spot_y,portdelta(:,1),delta_y)
spot(:,1) and portdelta(:,1) are what I would like to plot and their length is 108. I am not sure what am I doing wrong.
Can anyone please help? Thank you in advance.

Antworten (1)

Walter Roberson
Walter Roberson am 7 Apr. 2012
Well, length(spot_y) isn't 108, and neither is length(delta_y).
It would be unusual to be plotting data with variable x coordinates but with regularly spaced y coordinates.
I wonder if you meant
plotyy(spot(:,1),portdelta(:,1), spot_y, delta_y)
Or maybe you want
spot_y = linspace(3000, 13000, size(spot,1)) .';
delta_y = linspace(-1, 1, size(delta_y,1)) .';
plotyy(spot(:,1),spot_y,portdelta(:,1),delta_y)

Kategorien

Mehr zu Two y-axis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by