Aiming to solve function and have one of the variables be a minimum value:

1 次查看(过去 30 天)
syms r x
a = 100;
Cp = .70;
b = .50206;
c = 67.402;
d = 1.2;
e = .0277777778;
eqn = ((100*Cp*x)-(b*x*r*r))/((100*Cp*x)-(c/r)-(b*x*r*r)) == exp(d*acos(e*r));
solx = solve(eqn, x)
[r, fval] = fminsearch(matlabFunction(solx),[1 1])
So I know the last part is wrong. But I am given the "eqn" and I want X to be a minimum value. I am not sure which matlab method I should use to make this happen. I tried to use fminsearch, but it refuses to solve it that way, and I was wondering if theres another method I am unaware of. The r value can be variable and what it ends up being isn't important to me.
Thanks!

采纳的回答

Birdman
Birdman 2020-3-27
The key point here is to define solx as a function of r. Try the following code:
syms r x
a = 100;
Cp = .70;
b = .50206;
c = 67.402;
d = 1.2;
e = .0277777778;
eqn = ((100*Cp*x)-(b*x*r*r))/((100*Cp*x)-(c/r)-(b*x*r*r)) == exp(d*acos(e*r));
solx(r) = solve(eqn, x)
[r, fval] = fminsearch(matlabFunction(solx),1)
  1 个评论
Samy Abisaleh
Samy Abisaleh 2020-3-27
This works out perfectly. I believe the mistake I made was in the fminsearch, I needed the final value to be one term and I had it as two. If you look above, you can see at the end I had it as [1 1] and I needed it to be [1].

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by