This is the actual question: Write a MATLAB function which determines the minimum and maximum values of the function f(x,y)=e−x2 siny over two intervals: (i) x = -3:1:3, y = -3:1:3 and (ii) x = -3:0.1:3, y = -3:0.1:3. f(x,y) should be its own function and have inputs x and y and output the value of the function at said inputs. Use feval to evaluate the function.
How to write a function which determines the minimum and maximum values of a two input function over two intervals?
6 views (last 30 days)
Show older comments
I have no idea how to do this problem. The only thing I know is that I have to use the meshgrid command. Also I am not allowed to use built in commands like fminbnd() and such. I think the only ones I can use are min() and max() and find() to find the coordinates. Help please!!!
Thank you
Answers (1)
Roger Stafford
on 14 Nov 2013
Presumably you are expected to use 'meshgrid' to create a mesh of all possible combinations of your two inputs over their respective intervals using finely divided subintervals in each. Then the function is to be calculated for each possible combination and 'max' and 'min' applied to the result. Of course no matter how fine these subdivisions are, you will only have approximate values for the maximum and minimum. (I don't think you need the 'find' function.)
To achieve ultimate accuracy on such a problem you would need iterative procedures such as are used in 'fminbnd' in seeking the precise minima and maxima using ever smaller search areas. Somehow, from the way your problem is stated I don't think you are expected to do that.
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!