How to solve equations with more unknowns

I want to write a code to find pi,pj and pk. How to solve these equations, all x and y terms are known.
Eq1 : x=pi.xi + pj.xj + pk.xk
Eq2 : y=pi.yi + pj.yj + pk.yk
Eq3 : pi + pj + pk = 1

8 Comments

TADA
TADA on 9 Nov 2018
Edited: TADA on 9 Nov 2018
seems like a system of 3 linear equations with 3 parameters. If I got it right, all you need is to declare your parameters (pi, pj, pk) as symbolic variables, and send these equations to solve function.
TADA its working. Bruno i am doing a project on Color Shift Keying for visible light communication for which i am trying to convert chromaticity coordinates(x,y) into a 3-element vector P which is the power of LEDs and the xi and yi etc are chromaticity values at the central wavelengths of RGB LEDs.
@awais Saeed, I think bruno ment what do you mean by the syntax
pi.xi
I assumed you ment multiplation, which you should right like that so it is clear
pi*xi
Instead of solve() you can probably use the numeric \ operator.
TADA its working.
is pi a struct with values?
Yes it is multiplication(pi*xi). Pi,pj,pk are variables not struct.
@walter roberson i have solved the equations with solve() command. But how with numeric \ operator

Sign in to comment.

 Accepted Answer

A = [xi, xj, xk;
yi, yj, yk;
1, 1, 1];
b = [x;
y;
1];
sol = A\b;
pi = sol(1); pj = sol(2); pk = sol(3);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!