Finding varible in equation from vectors.

1 vue (au cours des 30 derniers jours)
Giuseppe
Giuseppe le 26 Mar 2014
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,

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by