フィルターのクリア

Fzero 3 variables 1 equation optimisation

2 ビュー (過去 30 日間)
James
James 2013 年 5 月 10 日
I have this equation:
(P.^3)+(0.5.*H)+Q+(1/sin(H*P))=0
I have this function saved in its own func.m file:
function A = func(x,y)
A = (P.^3)+(0.5.*H)+Q+(1/sin(H*P))
end
So it has 3 variables: P,H,Q and I cannot rearrange it in terms of H.
I need to find out for each combination of (P,Q) i.e. for P from 1 to 5 and Q from 1 to 5 the value of H for which A=0. This should give me a matrix of the 25 H values.
I am aware to use "fsolve" but having problems how to do this.
I have looked on Mathworks help which says to do this:
fun = @cos; % function
x0 = [1 2]; % initial interval
x = fzero(fun,x0)
Though I don't understand how to adapt that first line (with the @) to call my function and how to automatically find the interval.
At the moment what I do is choose a value of P and a value of Q and a range for H. Pass these 3 to the function and get back a list of A values. Look at A values to see where it passes through 0 and then set the corresponding values of H either side as the interval in the second bit of code of the fzero function. This gives me a result. Repeat for the other cominations of (P,Q). This is not the best way to do it I know and it time consuming.
How do I code so that I can put in a range of P and a range of Q, and get back a matrix of H values for which that equation equals zero? The intention is then to plot H in terms of P and Q as axes.

採用された回答

Matt J
Matt J 2013 年 5 月 10 日
Why not just do
H=2*(A-Q-P.^3)
  8 件のコメント
Matt J
Matt J 2013 年 5 月 11 日
編集済み: Matt J 2013 年 5 月 11 日
I should have included a graph
Why? Are we talking about a different function now? As I explained, it is very easy to understand graphically and analytically where the search intervals are going to lie for the function
(P.^3)+(0.5.*H)+Q+(1/sin(H*P))
James
James 2013 年 5 月 11 日
I'm just getting muddled now. The main point of this question was help with understanding fzero and that is working now.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOptimization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by