Minimizing and plotting equations with variables

조회 수: 2 (최근 30일)
A
A 2012년 11월 12일
Hello!
This is probably quite a rudimentary question, but I am not familiar with solving equations in matlab, and would greatly appreciate some help.
I have the formula:
f= x*mp + (A-x)*mn - av*A + as*A^(2/3) + ac*x^(2)/A^(1/3) + aa*(x^2 - A/2)^2/A;
where is the variable and all other parameters are taken as constants.
This should minimize to give:
xknot=(A/2)*((mn-mp+aa)/(ac*A^(2/3)+aa));
Then I want to plot the expression
E=f(xknot,A) - m(xknot-2,A-4) - constant
where the brackets imply "as a function of"
I have not even been able to minimize the function in matlab to get the correct xknot defined above.
This is what I have been using so far:
syms x mp mn A av as ac aa
f= x*mp + (A-x)*mn - av*A + as*A^(2/3) + ac*x^(2)/A^(1/3) + aa*(x^2 - A/2)^2/A;
g=diff(f,x);
solve(g)
I do not know how to express the rest of it in matlab.
Thank for your help!

답변 (1개)

Walter Roberson
Walter Roberson 2012년 11월 12일
You missed an important step in minimization: always also consider the behavior of the function at the extremes of the allowed ranges.
If you examine your function, you will find that except in the region abs(x) <= sqrt(A/2), and once the constant m*(p-n) has been overcome, that the function has opposite signs between negative x and positive x, and that the contributions of x become infinite as x approaches one of the infinities. The signs of A and aa determine which infinity is approached, but you know that the two infinities will be different sign. Therefore, unless x is imposed a restricted range, the minimum of f(x) is -infinity and not the expression you show.
  댓글 수: 2
A
A 2012년 11월 12일
Okay, thank you. How can I code for the rest of the problem? I.e. finding E as a function of f?
Walter Roberson
Walter Roberson 2012년 11월 12일
Et = subs(f, {x, A}, {xknot, A}) - subs(m, {x, ??}, {xknot, A-4}) - constant;
E = matlabFunction(Et, A);
In the above, replace ?? by the name of the variable in m that is to become A-4 .
Note that you will need to give values to mp mn av as ac aa before you plot. You imply in your question that E should be plottable, so presumably you would have definite values for them by then; you would subs() those definite values in before you used matlabFunction(). Alternately it is possible to tell matlabFunction to make all of those into parameters that need to be passed into the function, and to indicate which order they should appear in.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by