Borrar filtros
Borrar filtros

Error using | "Inputs must have the same size."

6 visualizaciones (últimos 30 días)
Negar
Negar el 6 de En. de 2015
Comentada: Negar el 6 de En. de 2015
Hello everybody,
I have made the attached kmeans clustering algorithm for un-predefined number of clusters. It is supposed to update each cluster center until either the cluster memberships are not changed, or the local distortion improvement corresponding to each cluster is less than a threshold. But I receive this error at line 113: Error using | "Inputs must have the same size."
and when I change it to , I get this error: Operands to the and && operators must be convertible to logical scalar values.
Could anyone suggest a solution?

Respuesta aceptada

Guillaume
Guillaume el 6 de En. de 2015
I'm assuming the error comes from this line
if (membership_idx == temp_idx) || (L < 0.7)
and occurs before membership_idx or temp_idx (or both) is not scalar.
You would have to wrap the first expression in all or any depending on the behaviour you want:
if all(membership_idx == temp_idx) || (L < 0.7)
  1 comentario
Negar
Negar el 6 de En. de 2015
Yes , its true, both membership_idx and temp_idx are vectors. Now its perfectly working. Thank you so much for taking the time!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by