How can I calculate x for each associated Ho?

1 Ansicht (letzte 30 Tage)
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi am 30 Mär. 2015
Beantwortet: Star Strider am 30 Mär. 2015
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?

Akzeptierte Antwort

Star Strider
Star Strider am 30 Mär. 2015
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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by