I have data point which fits the line y=mx+c ? How can I write code for this?

25 次查看(过去 30 天)
I have data point which fits the line y=mx+c ? How can I write code for this?

回答(2 个)

sixwwwwww
sixwwwwww 2013-12-7
write as follow
x = 0:100;
m = 3;
c = 4;
y = m * x + c;
plot(x, y)
  7 个评论
sixwwwwww
sixwwwwww 2013-12-7
The problem is that in order to plot the equation you need to have 3 known values and one unknown value because there 4 values in equation x, y, m and c. So you should atleast have three values or if you just plot some random values of x and y and then want to find m and c then using cftool is the best option
sixwwwwww
sixwwwwww 2013-12-8
编辑:sixwwwwww 2013-12-8
If you are given values of x and y then you can compute m and c as follow:
fitvars = polyfit(x, y, 1);
m = fitvars(1);
c = fitvars(2);

请先登录,再进行评论。


chitresh
chitresh 2013-12-7
>>syms x y m c
>> solve(' y = m * x + c')
i think this gone solve your question, if it is solved accept the answer
  4 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by