The 'plotData' command does not plot the complete set of binary data

1 vue (au cours des 30 derniers jours)
Manyu Hati
Manyu Hati le 29 Août 2021
Dear Matlabers,
I am trying to plot binary data by using the command called 'plotdata'. In the plot the '+' symbols represent the cases with y==1 and the yellow 'o' symbols represent the cases with y==0. If you open the excel file 'Testset1.xlsx', you can see that there are 16 test samples, and the command only plots 9 of them.
Could you help me to fix this issue, in order for the command to plot the complete 16 samples?
Below I paste the 5 lines of code and the excel file:
data=xlsread('Testset1','Final');
X = data(:, [1, 2, 3, 4]);
y = data(:, 5);
data_X=[X(:,3),X(:,4)];
plotData(data_X, y);
Many thanks,
MH

Réponses (1)

Star Strider
Star Strider le 29 Août 2021
As ‘Udata4’ demonstrates, there are only 9 unique values.
So all the points are plotted, however only 9 of them are different. The 7 that are the same are overplotted on top of each other.
format short g
data = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/724374/Testset1.xlsx')
data = 16×5
0.21 30000 2.34 6.69 0 0.21 30000 2.34 7.11 0 0.21 30000 2.34 7.53 1 0.21 30000 2.34 7.95 1 0.21 30000 2.34 8.37 1 0.21 30000 2.34 8.78 1 0.21 30000 2.34 9.2 1 0.21 30000 2.34 9.6 1 0.21 30000 2.34 10 1 0.205 30000 2.34 6.69 0
Lv = data(:,5) == 1;
figure
plot(data(Lv,3), data(Lv,4), '+r')
hold on
plot(data(~Lv,3), data(~Lv,4), 'ob')
hold off
grid
Udata4 = unique(data(:,4),'stable')
Udata4 = 9×1
6.69 7.11 7.53 7.95 8.37 8.78 9.2 9.6 10
.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by