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

41 visualizzazioni (ultimi 30 giorni)
RS il 7 Dic 2013
Commentato: Image Analyst il 15 Dic 2013
I have data point which fits the line y=mx+c ? How can I write code for this?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (2)

sixwwwwww il 7 Dic 2013
write as follow
x = 0:100;
m = 3;
c = 4;
y = m * x + c;
plot(x, y)
##### 7 CommentiMostra 5 commenti meno recentiNascondi 5 commenti meno recenti
sixwwwwww il 7 Dic 2013
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 il 8 Dic 2013
Modificato: sixwwwwww il 8 Dic 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);

Accedi per commentare.

chitresh il 7 Dic 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
##### 4 CommentiMostra 2 commenti meno recentiNascondi 2 commenti meno recenti
chitresh il 15 Dic 2013
Image Analyst il 15 Dic 2013
And officially Accept answers in more than 30 other questions that you've asked.

Accedi per commentare.

### Categorie

Scopri di più su Interpolation in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by