could anyone help me to solve the following issue.
1 回表示 (過去 30 日間)
古いコメントを表示
I am having two different values of centroids generated randomly by the code to be 3 and 5 for 6 users.
As a result i am getting
centroids =3
centroids =5
in my command window
Now i need to begin my iteration so i used for loop in my code:
for iteration=1:iterations %iterations=3;
distances=zeros(users,centroids,1) %users=6
.
.
end.
But the code executes by taking into consideration only the centroids=5 in for loop and it does not consider centroids=3.
But for me the for loop should execute first by taking centroids=3,then followed by centroids=5 when iterations begins.
could anyone please help me on this.
0 件のコメント
回答 (1 件)
KSSV
2019 年 5 月 7 日
for iteration=1:iterations %iterations=3;
if i == 1
centroids = 3 ;
else
centroids = 6 ;
end
distances=zeros(users,centroids,1) %users=6
.
.
end.
9 件のコメント
Walter Roberson
2019 年 5 月 8 日
Your existing code is too broken for a meaningful correction to be made by us. Too many places where we have no idea why you would even consider doing things the way you are doing them.
That is why I spent a bunch of time trying to figure out what the intended purpose of the code was -- not what the problem was that had to be solved, but rather trying to figure out what it was that you thought you had to implement along the way to solving what-ever it is you are trying to solve. I came up with a self-consistent framework for what you might have been trying to do, and I implemented it.
If my description of the goal of your code (not the current operation of your code but what the aim of the code is) is not correct, then I am not able to assist you, as your code as posted has no consistent logic in the form it is in, and cannot be repaired except by re-thinking what the purpose of the code is and going back to start over.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!