Finding varible in equation from vectors.

1 view (last 30 days)
I have
x = [1 2 3]
y = [1 2 1]
m = [1 -1 0]
For the equation y = mx +c (linear expression) I want to find c (y intercept) for each. i.e here
1=1*1 + c (equation 1)
2=-1*2 + c (equation 2)
1=0*3 + c (equation 3)
How would I write this as a vectorized code where the values for c are stored in a matrix. Note I want to find c for each equation not for all. I can't use built in functions. I think I have to use ==? It must hold true if there was more equations or there values were changed.
Thanks,

Accepted Answer

Mischa Kim
Mischa Kim on 26 Mar 2014
Giuseppe, use
c = y - m.*x

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!