Why do I receive a given error?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
if (((Motor_Speed)<=(SleepSpeedThreshold_int_dbl))&&(Tref_Ramp ==0))
timer_KeyOFF = timer_KeyOFF + 0.01;
else
timer_KeyOFF =0;
end
For above code getting a given error
Expected a scalar. Non-scalars are not supported with logical operators. Instead, use ALL to convert matrix logicals to their scalar equivalents. State 'KeyOFF' in Chart 'State_Machine/Control Algorithm': if (((Motor_Speed)<=(SleepSpeedThreshold_int_dbl))&&(Tref_Ramp ==0))
0 commentaires
Réponses (1)
Torsten
le 29 Mar 2024
Modifié(e) : Torsten
le 29 Mar 2024
According to the error message, MotorSpeed, SleepSpeedThreshold_int_dbl and/or Tref_Ramp are arrays, not scalars.
So if you want to have all elements of Motor_Speed to be smaller or equal than the corresponding elements of SleepSpeedThreshold_int_dbl and all elements of Tref_Ramp to be equal to 0, use
if all(Motor_Speed(:) <= SleepSpeedThreshold_int_dbl(:)) & all(Tref_Ramp(:) == 0)
0 commentaires
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!