Using clusterdata() to plot clusters using plot(). "Vectors must be the same length"
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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),:)');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Approximation, Clustering, and Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!