Using clusterdata() to plot clusters using plot(). "Vectors must be the same length"
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I am attempting to use the cluseterdata() function using this tutorial:
To plot clusters for my own dataset. Here is the code i've written so far:
data=file02;
rng('default')
dates=file02.Date;
x=dates;
y=[file02.Thermal,file02.Nuclear,file02.Hydro];
clusters=clusterdata(y,'maxclust',16,'distance','correlation','linkage','average');
display(clusters);
for c = 1:16
subplot(4,4,c);
plot(x,y((clusters == c),:)');
axis tight
end
The "dates" variable is a 4945x1 datetime table and the y variable is a 4945x3 double table. When i try to graph the clusters of this data, I get an error "Vectors must be the same length". I know that the length of cluster data at 'c' will be different for each iteration. But, the "x" variable will be of constant length 4095. I am curious on how to plot the clusters with the date being constant on the x axis?
0 Kommentare
Antworten (1)
Seth Furman
am 18 Okt. 2020
You'll need to decide what you want the x-values to be when y((clusters == c),:)' does not have 4095 elements.
I suspect you want something like the following.
plot(x(clusters == c),y((clusters == c),:)');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Cluster Analysis and Anomaly Detection finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!