Finding varible in equation from vectors.

1 次查看(过去 30 天)
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,

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by