필터 지우기
필터 지우기

how to solve the following equation?

조회 수: 1 (최근 30일)
kimy
kimy 2021년 11월 24일
댓글: Star Strider 2021년 11월 25일
Dear all,
I have a easy question since I am not familiar with matlab. Hope you can give me some tips? My question is as belows.
a=[1,2,3];
a=((b-2).*(b+1))./((b+3).*(b-1)):
b=?
I would like to solve b. Should I use for loop and assume a initial value of b then solve it iteratively? but I forget how to achieve this programme. Thanks for your attention.

채택된 답변

Star Strider
Star Strider 2021년 11월 24일
Try this —
a=[1,2,3];
afcn = @(b) ((b-2).*(b+1))./((b+3).*(b-1));
[estb,fval] = fminsearch(@(b) norm(afcn(b) - a), rand) % Estimate For All 'a'
estb = 0.7016
fval = 1.4142
for k = 1:numel(a)
[estba(k),fvala(k)] = fminsearch(@(b) norm(afcn(b) - a(k)), rand); % Estimate For All 'a'
end
estba
estba = 1×3
0.3333 0.7016 0.8117
fvala
fvala = 1×3
1.0e+-4 * 0.2770 0.1710 0.5080
bv = linspace(0, 1.5);
figure
plot(bv, afcn(bv))
hold on
plot(estb, afcn(estb), 'sr', 'MarkerSize',20)
plot(estba, afcn(estba), 'pg', 'MarkerSize',15, 'MarkerFaceColor','g')
hold off
grid
Experiment to get different results
.
  댓글 수: 2
kimy
kimy 2021년 11월 25일
Thank you so much. It works properly.
Star Strider
Star Strider 2021년 11월 25일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by