Solve (a*B) + (c*D) = E without the Symbolic Toolbox

Solve (a*B) + (c*D) = E without the Symbolic Toolbox
where, B, D, & E are all known.
If the Symbolic Toolbox was available it would looke like this:
syms a c
eqn = ((a*B) + (c*D)) / E == 1;
x = solve( eqn );
Any help would be greatly appreciated.
(Available toolboxes include: Image Processing, Signal Processing, & Statistical and Machine Learning

 채택된 답변

Star Strider
Star Strider 2020년 9월 25일

0 개 추천

This would seem to be homework, and for homework we only give guidance and hints.
I would set it up as an implicit equation (so it equals 0), and use fsolve. To do this, ‘a’ and ‘c’ would have to be parameterized as ‘p(1)’ and ‘p(2)’, and you would have to code it as an anonymous function. .

댓글 수: 10

I promise you, this is not homework.
O.K.
f = @(p) p(1)*B + p(2)*D - E;
p0 = [1;1];
P = fsolve(f, p0);
with:
a = P(1)
c = P(2)
Different values for ‘p0’ may be necessary. That may require a bit of experimentation.
Except you can't use one equation to compute a solution for two variables. Yes. You will get A solution. And depending on the initial values posed, you will get completely different solutions for every set of initial values.
Definitely true. However if we had vectors for ‘B’. ‘D’ and ‘E’, this becomes a simple linear regression problem, solved with the mldivide,\ operator.
We only know the information we have been given, and thus far, that indicates that the constants are scalars.
And ‘B’. ‘D’ and ‘E’ are all vectors so this would be the next step. Thank you!
I was looking at fsolve and @ but had never used them before and was constantly getting errors. Thank you fro clearing it up!
As always, my pleasure!
Is each B D E tuple to be solved independently, or are you needing to find a single a, c that together are "best fits" over all of the B D E together?
If you have more than one B D E and they are considered to be related, then you can find both a and c simultenously as best-fit using techniques similar to what Ivo Houtzager shows, or using the \ operator.
I'm needing to find a single ‘A’ & ‘C’ that best fits ‘B’, ‘D’, and ‘E’. I think the ‘\’will work, as described above by Star Strider, but I will definitely look at Ivo Houtzagar's link. Thank you.
Experiment with something like this:
p = [B(:) D(:)] \ E(:);
a = p(1)
c = p(2)
If I understand correctly what you are doing, that should work.
To also get statistics with the parameter estimates, use the regress or fitlm functions, depending on what you want to do.

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

추가 답변 (3개)

Walter Roberson
Walter Roberson 2020년 9월 25일

0 개 추천

((a*B) + (c*D)) / E == 1
((a*B) + (c*D)) == 1 * E
a*B + c*D == E
a*B == E - c*D
a == (E-c*D) / B
a == E/B - D/B * c
a == (-D/B) * c + (E/B)
Parameterized:
c = t
a = (-D/B) * t + (E/B)
You have one equation in two variables; you are not going to be able to solve for both variables simultaneously.
Ivo Houtzager
Ivo Houtzager 2020년 9월 25일
편집: Ivo Houtzager 2020년 9월 25일

0 개 추천

A = E*pinv([B; D]);
a = A(1);
c = A(2);
Steven Lord
Steven Lord 2020년 9월 26일

0 개 추천

This is a generalization of Cleve's simplest impossible problem. Cleve's has B = 1/2, D = 1/2, E = 3.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2020년 9월 25일

댓글:

2020년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by