MATLAB:矩阵数据散点图



我正试图在MATLAB上使用以下代码执行XY矩阵的散点图,每个矩阵的大小都为54x365。数据是从excel中提取的。

clc
clear
A = xlsread('Test_data.xlsx', 'Sheet 1', 'F3:NF56');
B = xlsread('Test_data.xlsx', 'Sheet 2', 'F3:NF56');
scatter (A,B)

尽管它们的大小相似,但MATLAB会产生以下语句:

Error using scatter (line 44)
X and Y must be vectors of the same length.
Error in Untitled2 (line 11)
scatter(A,B)

注意以下内容:

A = [ A, B, C, D, E ;
F, G, H, I, J ]
B = [ a, b, c, d, e ;
f, g, h, i, j ]

绘制变量(A,a)(B,b)等以便产生散点图。

我需要帮助来绘制散点图。非常感谢。

将数组重新整形为行向量可以允许scatter()函数绘制数据。这里,阵列被重新成形为具有在每个阵列中为1乘以Number_Of_Values的尺寸。

%Generating random test data%
A = rand(54,365);
B = rand(54,365);
%Reshaping to allow plotting%
Number_Of_Values = numel(A);
A = reshape(A,[1 Number_Of_Values]);
B = reshape(B,[1 Number_Of_Values]);
scatter(A,B);

使用MATLAB R2019b运行

最新更新