Can I solve for multiple variables in an equation?

1 vue (au cours des 30 derniers jours)
Hunter Herrenkohl
Hunter Herrenkohl le 10 Mar 2019
Commenté : Walter Roberson le 12 Mar 2019
I have
vcuaamo = 13.58823529;
sjuaamo = -4.470588235;
vcuhome = 19.125;
sjuhome = -2.111111111;
vcuaway = 8.666666667;
sjuaway = -7.125;
vculast7 = 15.57142857;
sjulast7 = 2.714285714;
vcuprepoints = 71.9;
sjuprepoints = 65.7;
form = 12
abcd = randfixedsum(4,1,1,0,2)
dcba = sort(abcd,'descend')
a = dcba(1,1), b = dcba(2,1), c = dcba(3,1), d = dcba(4,1)
prediction = (vcuaamo-sjuaamo)*a+(vcuhome-sjuaway)*c+(vculast7-sjulast7)*b+(vcuprepoints-sjuprepoints)*d
randfixed sum just gives me a 4x1 matrix of random numbers between 0-2 that add up to equal 1 (because i needed 4 random variables to equal 1).
I would like to solve for what combo of a,b,c,d equals 12. Is there anyway to do that?

Réponses (1)

John D'Errico
John D'Errico le 10 Mar 2019
Modifié(e) : John D'Errico le 11 Mar 2019
Sigh. It looks like this is a followup to your last question. But it is COMPLETELY different. And you cannot use randfixedsum, which applied to the question as you posed it before. Change the question, and you cannot just use the last answer. Sorry, but it does not work that way.
Now, you are apparently asking for a set of "random" numbers, such that...
a + b + c + d = 1
(vcuaamo-sjuaamo)*a+(vcuhome-sjuaway)*c+(vculast7-sjulast7)*b+(vcuprepoints-sjuprepoints)*d == 12
a >= b*c*d
b >= c*d
Where...
vcuaamo-sjuaamo
ans =
18.058823525
vcuhome-sjuaway
ans =
26.25
vculast7-sjulast7
ans =
12.857142856
vcuprepoints-sjuprepoints
ans =
6.2
So the second equality reduces to
18.058823525*a + 12.857142856*b + 26.25*c + 6.2*d == 12
Is that now your goal? Will there be other changes later, so I'll be chasing a moving target?
Here are a set of numbers, as the rows of abcd. See that each row of numbers satisfies all of your requirements.
abcd
abcd =
0.471705866365957 0.0132926640255532 0.00586694322713018 0.509134526381359
0.346155290576649 0.0793275924323071 0.0582000190305242 0.51631709796052
0.206800938580258 0.155886157573227 0.115203378769798 0.522109525076716
0.34861314533669 0.129921911760084 0.0399476061967838 0.481517336706442
0.419550109712593 0.10999136195574 0.00460853264631487 0.465849995685353
0.315940580622874 0.0977203799366216 0.0699639840811281 0.516375055359376
0.312054299604144 0.291064651694339 0.00806704060428341 0.388814008097233
0.323553078479239 0.0824424061823778 0.0705341778551503 0.523470337483233
0.330141930351684 0.152636044152945 0.0433309306162425 0.473891094879129
0.450907712422767 0.0236539907983886 0.0147280307460139 0.510710266032831
a = abcd(:,1);b = abcd(:,2);c = abcd(:,3);d = abcd(:,4);
a+b+c+d
ans =
1
1
1
1
1
1
1
1
1
1
a > b.*c.*d
ans =
10×1 logical array
1
1
1
1
1
1
1
1
1
1
b > c.*d
ans =
10×1 logical array
1
1
1
1
1
1
1
1
1
1
abcd*[18.058823525 12.857142856 26.25 6.2]'
ans =
12
12
12
12
12
12
12
12
12
12
Is that what you need?
  7 commentaires
Hunter Herrenkohl
Hunter Herrenkohl le 12 Mar 2019
it is a >b , a>c and a>d
Walter Roberson
Walter Roberson le 12 Mar 2019
Under the constraint a > 0, b > 0, c > 0, d > 0, a > b, a > c, a > d, b > c, b > d, c > d, then there does not appear to be solutions. The lowest prediction value appears to be approximately 15.48 under those constraints.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by