フィルターのクリア

How can I calculate x for each associated Ho?

1 回表示 (過去 30 日間)
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi 2015 年 3 月 30 日
回答済み: Star Strider 2015 年 3 月 30 日
Hi, I tried to calculate x value for each Ho in the following equation by using fzero function. but there is an error which avoids running the code properly, I am interested in having 7 values for x, eventually 7 tetas in the equations:
Equations:
Jo=[0.74]; Jw=[0.35 0.25 0.19 0.12 0.08 0.06 0.04]; Jmix=Jo+Jw; ew=Jw./Jmix; Hw=((1+0.35.*(1-ew))).*ew; Ho=1-Hw;
fun=@(x) 2*pi.*Ho-2*pi+x-sin(x); teta=fzero(fun,[0 2*pi])
error:
Operands to the and && operators must be convertible to logical scalar values.
Error in fzero (line 423) while fb ~= 0 && a ~= b
Error in a (line 4) teta=fzero(fun,[0 2*pi])
is there anybody to help me how I can remove this error?

採用された回答

Star Strider
Star Strider 2015 年 3 月 30 日
Use a for loop and iterate through the values for ‘Ho’:
fun=@(x,Ho) 2*pi*(Ho-1)+x-sin(x);
for k1 = 1:length(Ho)
teta(k1)=fzero(@(x) fun(x,Ho(k1)),[0 2*pi]);
end
teta % Display Results
produces:
teta =
2.8164 2.5552 2.3515 2.0350 1.7840 1.6225 1.4175

その他の回答 (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