【问题标题】:How to scatter dots using time series data(X axis) and ratio(Y axis) using matlab如何使用matlab使用时间序列数据(X轴)和比率(Y轴)散布点
【发布时间】:2021-02-07 19:09:02
【问题描述】:

我想在图表上用 HH:mm:ss 在 x 轴上散布点,在 y 轴上用百分比。 首先,我通过 Matlab 上的菜单从 excel 中导入数据。

我使用下面的代码转换为时间格式(X值,它显示为时间格式)。

t =days(VarName6);
t.Format='hh:mm:ss';

然后,不知何故出现了一条错误消息,说“为了从持续时间更改为数字格式,请选择 SECONDS、MINUTES、HOURS、DAYS、YEARS 之一”。

无论如何,“t”是时间(HH:MM:SS)格式(其中 250 个),而“VarName5”是数字(0.0471 等)(其中 250 个)。 我想将 x 轴设置为从凌晨 5 点到凌晨 1 点。并将 Y 轴单位转换为比率(%)。 我应该如何将代码更改为?

hold on;
sz=140;
scatter(t,VarName5,sz,'d');
grid on 
xlabel('time'); 
ylabel('ratio');
title('Samsung Station')
hold off
saveas(1,'figure 1.jpg')   

我不断得到下面的图像作为图表。但我想在图表上散布 250 个点。

【问题讨论】:

  • 我目前使用的是2015a版本

标签: matlab plot scatter-plot time-format


【解决方案1】:

轰隆隆!很简单

figure(1)
hold on;
scatter(datenum(t),VarName5*100,'b');
grid on 
xlabel('time'); 
ylabel('ratio(%)');
%title('Samsung Station')
datetick('x', 'HH:MM:SS', 'keeplimits')
hold off
saveas(1,'figure 1.jpg')

【讨论】:

    猜你喜欢
    • 2019-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 1970-01-01
    相关资源
    最近更新 更多