2
votes

I am trying to perform the scatter plot of X and Y matrices, each of size 54x365, with the following code on MATLAB. The data was extracted from excel.

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

Although they are of similar size, MATLAB produces the following statement:

Error using scatter (line 44)
X and Y must be vectors of the same length.

Error in Untitled2 (line 11)
scatter(A,B)

Note the following:

A = [ A, B, C, D, E ;
      F, G, H, I, J ]

B = [ a, b, c, d, e ;
      f, g, h, i, j ]

The variables (A,a), (B,b) and so on are plotted so as to produce a scatter plot.

I need help to perform the scatter plot. Thank you.

1
What are currently the sizes/dimension of matrices/vectors A and B shown in the MATLAB workspace panel to the right?MichaelTr7
Both are 54x365 double.Yuv

1 Answers

2
votes

Reshaping the arrays as row vectors may allow the scatter() function to plot the data. Here the arrays are reshaped to have dimensions that are 1 by Number_Of_Values in each array.

%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);

Ran using MATLAB R2019b