带有两个y轴的XY图Matlab [英] XY Plot with two y axis Matlab

查看:125
本文介绍了带有两个y轴的XY图Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建带有两个y轴的xy图.我有三组速度数据.我试图创建一个图,其中一个y轴表示速度的变化,另一个y轴表示距离.请参阅所附图片.但是,每组数据都取自x轴上的一个位置.我该怎么做?

I'm trying to create an xy plot with two y axis. I have three sets of velocity data. Im trying to create a plot with one y axis showing the variation of velocity and the other y axis showing distance. Please see the attached image. However, each set of data was taken at one position as seen on the x axis. How to I do this?

致谢,耶

推荐答案

您可以归一化速度数据并将其绘制在不同的x位置.但是,一旦速度变化太大,就期望曲线重叠.

You can normalize your velocity data and plot that at distinct x-locations. However, once your velocity changes are too large, expect the curves to overlap.

% define the x locations:  
xloc = [1 2 3];

% set up dummy velocity data:
y = linspace(0,1,101);
phi = linspace(0,pi,101);

vel(1,:) = sin(phi).*0.1;
vel(2,:) = sin(phi).*0.2;
vel(3,:) = sin(phi).*0.3;

% normalize with the global max velocity
vel_nondim = vel ./ max(max(vel));

% plot, using the defined x-locations
hold on
plot(xloc(1) + vel_nondim(1,:), y, 'g')
plot(xloc(2) + vel_nondim(2,:), y, 'b')
plot(xloc(3) + vel_nondim(3,:), y, 'r')

% x limits and ticks
xlim([0 4])
set(gca,'XTick',[1 2 3])

您将得到以下情节:

这篇关于带有两个y轴的XY图Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆