叠加两个具有不同轴的图 [英] Superimposing two plots with different axes

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

问题描述

我正在进行某种系统测试,其中我具有一组.mat文件形式的读数. 它在.mat文件中具有一个结构,其中一个字段为Measurement.它具有多个数组(例如空气质量流量,速度,加速度,碳含量),还具有诸如时间和值之类的字段.

I am working on a some sort of System test wherein i have a set of readings in the form of a .mat file. It has a structure in the .mat file with one field as Measurement. It has several Arrays(e.g air mass flow, velocity,acceleration, carbon content) which further have fields like time and value.

我需要针对各自的时间绘制不同的字段值.

I Need to plot different field valus against the respective times.

  • 我有两个字段,分别是速度和加速度.我需要将其绘制在同一条曲线上并进行网格比较.但是两者的y轴都不同.

  • I have two fields as velocity and acceleration. I Need to plot it on the same curve with grids on for the comparison. But the y axis for both are different.

速度y轴为(0:20:120),应显示在左侧,加速度y轴为:(0:2:12),其应显示在右侧.
我为此编写了以下代码:

the velocity y-axis is: (0:20:120), which should be displayed on the left side and the acceleration y-axis is: (0:2:12) which should be displayed on the right side.
I wrote the following code for this:

plot(Measurement.(Measurement.VehV_v.time),Measurement.VehV_v.value)
grid on
set(gca,'xtick',[0:500:2000])
set(gca,'ytick',[0:20:120])
hold on
plot(Measurement.(Measurement.accel_w.time),Measurement.accel_w.value)
grid on
set(gca,'xtick',[0:500:2000])
set(gca,'ytick',[0:2:12])    

我直接从结构中读取值时,是否需要为此编写函数?

Do I need to write a function for that as I am directly reading the values from the structure?

轴不匹配,加速度曲线非常小.有人可以帮我吗?
我也想在此处添加图形图片,但是不幸的是这里存在一些错误.我希望没有图片,问题会很清楚.

The axis are not matching and the graph for acceleration is very small. Could anyone help me out with this ?
I also want to add a Picture of the Graphs here but unfortunately there is some error here. I hope the question is clear without the Picture.

  • 我认为我需要使用plotyy()函数,但是我无法实现它.

  • I think so that i Need to use plotyy() function but I am unable to implement it.

有人可以帮我吗?

推荐答案

是的,您想使用如果要将比例设置为特定值,则应在创建绘图时为轴创建钩子,例如

If you want to set your scales to particular values you should create hangles for the axis when creating the plot e.g.

[AX,H1,H2] = plotyy(time, velocity, time, acceleration);

其中AX在第一轴和第二轴上有两个元素,您可以设置这些元素

Where AX has two elements for the first and second axis which you can set e.g.

set(AX(1),'ytick',[0:20:120])

H1和H2用于设置适当数据的样式等.

H1 and H2 are used to set the style etc. of the appropriate data.

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

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