在 matlab 中绘制向量
我遇到这种情况,无法以正确的方式解决。问题是这样的: 我有3个向量:
- Vector1 = [name1 name2 name3 name4 ... nameN] (字符串名称)
- Vector2 = [time1 time2 time3 time4] (Double)
- Vector3 = [time1:name4 time2:name1 time3:name1 time4:name1] (double :String)
我想在matlab中执行以下操作:
1-将向量1放入Y轴并带有名称 - 我可以用这段代码来做到这一点:
set(gca, 'YTick',1:N, 'YTickLabel',Names(:,1))
2- 将向量 2 放在 X 轴上,以模拟时间线
3- 一旦我们有了 X 轴和 Y 轴,我想使用 3 个向量在图中绘制点
例如, 3 个向量包含连续的时间戳,并且在每个时间戳中执行 nameN,所以我想使用 3 个向量作为输入在图中绘制一个点。
有什么建议吗?提前致谢
I have this situation and I can't solve it in the proper way. The problem is this:
I have 3 vectors:
- Vector1 = [name1 name2 name3 name4 ... nameN] (string names)
- Vector2 = [time1 time2 time3 time4] (Double)
- Vector3 = [time1:name4 time2:name1 time3:name1 time4:name1] (double:String)
I want to do the following in matlab:
1- Put Vector 1 in Y axis with names
- I could do it with this code:
set(gca, 'YTick',1:N, 'YTickLabel',Names(:,1))
2- put Vector 2 in X axis with, to simulate time line
3- Once we have both axis X&Y I'd like to use the 3 Vector to plot point in the graph
For example, 3 Vector contains secuentially timestamps and in each timestamp is executed the nameN, so I'd like to plot a dot in the graph using 3 vector as input.
Any suggestion?Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将
vector3
中的名称转换为数字,然后才能调用plot
命令。例如
You need to convert the names in
vector3
to numbers, then you can call theplot
command.For example
一种方法是,
另外,我建议将向量1重命名为“比例”,将向量2重命名为“时间”,将向量3重命名为“值”。这应该有助于你清楚地了解你正在使用什么等等。希望这会有所帮助。
One way to do it is,
Also I suggest to rename vector1 to "scale", vector2 to "time", and vector3 to "values". That should help to get your mind clear about what you are using with what etc. Hope this helps.