How can I contour plot a custom function?
问题 I have a custom function which returns either 0 or 1 depending on two given inputs: function val = myFunction(val1, val2) % logic to determine if val=1 or val=0 end How can I create a contour plot of the function over the x,y coordinates generated by the following meshgrid? meshgrid(0:.5:3, 0:.5:3); This plot will just simply display where the function is 0 or 1 on the contour map. 回答1: If your function myFunction is not designed to handle matrix inputs, then you can use the function ARRAYFUN