필터 지우기
필터 지우기

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 CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by