首页 文章

MATLAB时间序列图xticks

提问于
浏览
1

我正在MATLAB中绘制脑电图时间序列 . 矢量是4097 * 1 . 记录信号的持续时间为23秒 . MATLAB绘图功能绘制y轴上的幅度和x轴上的样本数量的信号 . 但是,我需要x轴上的时间,刻度倍数为5秒 . 该图显示了x轴上的时间(从纸上看) . 我尝试使用'xticks'代码,但x轴保持不变 .

hFig = figure;
hAx = gca;
ts = 0:length(d); % the data time series
stairs(ts(2:end), d, 'LineWidth', 2);
xticks ([0 5 10 15 20 25 30])
hAx.XLabel.String = 'Time (Seconds)';

enter image description here

我感谢您的支持 . 谢谢 .

1 回答

  • 1

    你打算做的是 scale your X-axis 正确 . 请尝试以下方法:

    hFig = figure;
    hAx = gca;
    ts = 0:length(d)-1; % the X axis of data time series
    % Scale the X-axis to 23 seconds
    ts = ts * (23 / length(d));
    stairs(ts, d, 'LineWidth', 2);
    hAx.XLabel.String = 'Time (Seconds)';
    

    现在,您的X轴是一个简单的整数列表,等于样本数 . 如上所述正确缩放它们可以为您提供逼真的X轴 .

相关问题