How to define a function
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey guys. I am having a problem now and I really need help. I have to define a function which calculates the distance of a certain point from the center of the circle to determine is the point is in/on/outside of the circle. Suppose the radius is r, the center is (a,b). How can I use "If" and "return" to construct the problem? Thank you so much
0 commentaires
Réponses (1)
Joseph Cheng
le 29 Sep 2015
Modifié(e) : Joseph Cheng
le 29 Sep 2015
check the documentation on functions http://www.mathworks.com/help/matlab/ref/function.html. after that it'll look something along the lines of
function output = yourfunction(a,b,r,x,y)
%calculate distance from (x,y) and (a,b)
%if statements to check if
%distance is == r
%elseif distance is <r
%elseif distance is >r
%return
I do not understand why you'd need a return statement
0 commentaires
Voir également
Catégories
En savoir plus sur Logical 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!