如何在Matlab中将字符串用作绘制数据? [英] How to use string as data for plotting in Matlab?

查看:758
本文介绍了如何在Matlab中将字符串用作绘制数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在X轴上使用"A","B"和"C"之类的词在Y轴上显示其相应的属性.如何在X轴上写这些字符串而不是数字数据?

I want to use a words like, let's say, 'A', 'B' and 'C' on X-axis to show their corresponding properties on Y-axis. How can I write these strings on X-axis instead of numerical data?

推荐答案

使用轴手柄的'XTick''XTickLabel'属性.
这是一个简单的示例:

Use 'XTick' and 'XTickLabel' properties of the axes handle.
Here's a simple example:

x = 1:5;
y = rand(size(x));
plot(x, y, 'b')
set(gca, 'XTick',1:5, 'XTickLabel',{'A' 'B' 'C' 'D' 'E'})

这篇关于如何在Matlab中将字符串用作绘制数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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