How to set ranges for 2 different variables in the same loop?
Afficher commentaires plus anciens
I have a set of x and y values and I need to isolate and substitute the values which are within the range to a formula that I've already typed out, but it keeps coming up with the "Operands to the || and && operators must be convertible to logical scalar values."
This is the loop section of code =
while ((x < 40) & (x > 15) && (y < 25) & (y > 5))
deltaLdeltax = ((-(40 - x))/sqrt(((40-x)^2)+((y-10)^2)))+((x-15)/sqrt(((x-15)^2)+((y-25)^2)))+((x-10)/sqrt(((x-10)^2)+((y-5)^2)))
deltaLdeltay = ((y-10)/sqrt(((40-x)^2)+((y-10)^2)))+((-(25-y))/sqrt(((x-15)^2)+((y-25)^2)))+((y-5)/sqrt(((x-10)^2)+((y-5)^2)))
end
Réponse acceptée
Plus de réponses (1)
KSSV
le 20 Mai 2019
while ((x < 40) && (x > 15) && (y < 25) && (y > 5))
deltaLdeltax = ((-(40 - x))/sqrt(((40-x)^2)+((y-10)^2)))+((x-15)/sqrt(((x-15)^2)+((y-25)^2)))+((x-10)/sqrt(((x-10)^2)+((y-5)^2)));
deltaLdeltay = ((y-10)/sqrt(((40-x)^2)+((y-10)^2)))+((-(25-y))/sqrt(((x-15)^2)+((y-25)^2)))+((y-5)/sqrt(((x-10)^2)+((y-5)^2)));
end
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!