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

84 views (last 30 days)
RS on 7 Dec 2013
Commented: Image Analyst on 15 Dec 2013
I have data point which fits the line y=mx+c ? How can I write code for this?

sixwwwwww on 7 Dec 2013
write as follow
x = 0:100;
m = 3;
c = 4;
y = m * x + c;
plot(x, y)
sixwwwwww on 8 Dec 2013
Edited: sixwwwwww on 8 Dec 2013
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 on 7 Dec 2013
>>syms x y m c
>> solve(' y = m * x + c')
i think this gone solve your question, if it is solved accept the answer
Image Analyst on 15 Dec 2013
And officially Accept answers in more than 30 other questions that you've asked.

### Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by