How to define a function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Joseph Cheng
am 29 Sep. 2015
Bearbeitet: Joseph Cheng
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!