how to find the minimum value based on two independent value
古いコメントを表示
Hi, guys, i have a problem and dont know how to solve. i have two independent variale:x1, x2, y is dependent output value.i want to find when y will be the minimum value. I heard about surface response method is useful to solve this problem, but it is a little complicated. could you give me an advice to solve problem using matlab, thank you! here list the results
x1 x2 y
0.15 1.0 0.863
0.15 1.5 0.050
0.15 2.0 1.267
0.15 2.5 3.082
0.20 1.0 0.635
0.20 1.5 0.010
0.20 2.0 0.690
0.20 2.5 1.900
0.25 1.0 0.629
0.25 1.5 0.009
0.25 2.0 0.617
0.25 2.5 1.522
0.30 1.0 0.701
0.30 1.5 0.016
0.30 2.0 0.593
0.30 2.5 1.452
6 件のコメント
Andrew Newell
2015 年 3 月 17 日
Are you wanting to find where y is a minimum in a table like the one above, or are you trying to minimize a function?
Andrew Newell
2015 年 3 月 17 日
First, do you know how to assign the values in the table to x1, x2 and y?
suby
2015 年 3 月 18 日
suby
2015 年 3 月 18 日
Andrew Newell
2015 年 3 月 18 日
編集済み: Andrew Newell
2015 年 3 月 18 日
I think you're having trouble articulating what you really want. You talk about finding the minimum in a table, which is pretty trivial in this case because you can just eyeball the third column. The smallest value is 0.009, for which x1 = 0.25 and x2 = 1.5. However, you're talking about changing inputs and the minimum being "close to" x1=0.2 and x2=1.5. That implies there is a function that generates y. That is quite a different problem, involving optimization.
採用された回答
その他の回答 (2 件)
Andrew Newell
2015 年 3 月 18 日
I'm going to assume you're really trying to minimize a function of two variables and show how you can explore it to get some insight. First, I'll read your table in as a matrix:
M = [0.15 1.0 0.863;
0.15 1.5 0.050;
0.15 2.0 1.267;
0.15 2.5 3.082;
0.20 1.0 0.635;
0.20 1.5 0.010;
0.20 2.0 0.690;
0.20 2.5 1.900;
0.25 1.0 0.629;
0.25 1.5 0.009;
0.25 2.0 0.617;
0.25 2.5 1.522;
0.30 1.0 0.701;
0.30 1.5 0.016;
0.30 2.0 0.593;
0.30 2.5 1.452];
Now, a contour plot is a good idea, but that requires rearranging the points:
x1 = 0.15:.05:.3;
x2 = 1:.5:2.5;
[x1,x2] = meshgrid(x1,x2);
y = reshape(M(:,3),size(x1));
You'll find that [x1(:) x2(:) y(:)] gives you back your table. Now we'll plot the data:
contourf(x1,x2,y);
xlabel('x1')
ylabel('x2')
colorbar
This appears to be a fairly smooth function with a minimum somewhere near where you have guessed it is. You should be able to find an accurate minimum using fminsearch, but I can't tell you the details because you haven't told me what your function is.
1 件のコメント
Alan Weiss
2015 年 3 月 18 日
As with the other comments you have gotten, I am going to assume that there is a function, say myfun(x1, x2), that gives you your y variables. You are looking for the minimum of y, and want to know how to find the x1 and x2 that give the minimum.
This is a job for fminsearch. The only issue is getting your function of two variables to be a function of one vector variable x = [x1,x2]. Do it like this.
fun = @(x)myfun(x(1),x(2)); % x is a 2-component vector
solution = fminsearch(fun,[0.2,1.5]) % Put in a good start guess
Alan Weiss
MATLAB mathematical toolbox documentation
2 件のコメント
suby
2015 年 3 月 21 日
Image Analyst
2015 年 3 月 21 日
Explain why you want an interpolated value that does not exist in your table. What are you going to do with that information? Why is the value in the table not sufficient for what you want to do? In other words, describe your "use case".
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

