필터 지우기
필터 지우기

Plotting two plots with 2 different y axes

조회 수: 1 (최근 30일)
KKR
KKR 2012년 4월 7일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2012년 4월 7일
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)

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by