【问题标题】:how to plot column vector data along y-axis in matlab?如何在matlab中沿y轴绘制列向量数据?
【发布时间】:2015-08-23 13:30:42
【问题描述】:

我有这个行/列向量。

grades = [90, 100, 80, 70, 75, 88, 98, 78, 86, 95, 100, 92, 29, 50];
plot(grades);

在 MATLAB 中,我想沿 x 轴绘制等级值,沿 y 轴绘制索引 (1-14)。默认情况下,索引沿 x 轴绘制。如何实现?

【问题讨论】:

    标签: matlab plot


    【解决方案1】:
    grades = [90, 100, 80, 70, 75, 88, 98, 78, 86, 95, 100, 92, 29, 50];
    figure;
    plot(1:length(grades),grades); % Indices along X
    figure;
    plot(grades,1:length(grades)); % Indices along Y
    

    【讨论】:

    • 输出仍然没有变化。
    【解决方案2】:

    如果你想在 Matlab 中绘制数据。您必须为您感兴趣的所有轴定义数据集。

    在您的情况下,定义 x 轴数据和 y 轴数据。

    例如,您的 Y 轴数据将是

    grades = [90  100 80 70  75 88 98 78 86 95 100 92 29 50];
    

    对于您的 x 数据,您可以使用以下内容。

    X = 1:14;
    

    那么你有以下绘图命令

    plot(x,grades)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多