How to write a function which determines the minimum and maximum values of a two input function over two intervals?

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

2 件のコメント

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.
Ok, so this is my function to start with
%initial function
function [f]=f_x_y(x,y)
f=exp(-x.^2).*sin(y); end
This is my meshgrid for the first interval
%meshgrid
x=-3:1:3;
y=x;
[x,y]=meshgrid(x,y);
f=f_x_y(x,y);
I have no idea what to do from here..

サインインしてコメントする。

回答 (1 件)

Roger Stafford
Roger Stafford 2013 年 11 月 14 日
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.

1 件のコメント

Ok, so this is my function to start with
%initial function
function [f]=f_x_y(x,y)
f=exp(-x.^2).*sin(y); end
This is my meshgrid for the first interval
%meshgrid
x=-3:1:3;
y=x;
[x,y]=meshgrid(x,y);
f=f_x_y(x,y);
I have no idea what to do from here..
0 Comments

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

質問済み:

2013 年 11 月 14 日

コメント済み:

2013 年 11 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by