Using clusterdata() to plot clusters using plot(). "Vectors must be the same length"

3 ビュー (過去 30 日間)
Jacob Bennett
Jacob Bennett 2020 年 10 月 9 日
回答済み: Seth Furman 2020 年 10 月 18 日
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?

回答 (1 件)

Seth Furman
Seth Furman 2020 年 10 月 18 日
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),:)');

カテゴリ

Help Center および File ExchangeFunction Approximation, Clustering, and Control についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by