how to solve the following equation?
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Star Strider
on 24 Nov 2021
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'
for k = 1:numel(a)
[estba(k),fvala(k)] = fminsearch(@(b) norm(afcn(b) - a(k)), rand); % Estimate For All 'a'
end
estba
fvala
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 Comments
More Answers (0)
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!