Info

This question is closed. Reopen it to edit or answer.

Taking unlimited set of points between (0,0) and (255,255) , creating a linear equation for each 2, and creating the plot according to those unlimited options

1 view (last 30 days)
I've made a program that reads from the user a set of unlimited unique points. now i have to get linear equation of each following points ( by x ) and plot one graph using different equations for different X's
An example? sure. lets say I have 3 points: (0,0) (50,100) (200,200) I find the first equation y=2x and the second equation is y=(2/3)x + (200/3)
the first one is from 0 to 50 second one is from 50 to 200 how can i plot one graph that will show this exact function? but for many more functions ---from 0 to 50 =2x y= ---from 50 to 200 = (2/3)x+(200/3) ---from 200 to 201 = ... etc
Not sure how do you call it in english so search results was poor.
thanks

Answers (1)

Tejas M U
Tejas M U on 2 Jul 2014
One way you could do this is by finding the linear relation between two points, then creating a matrix for x, and then multiplying the matrix directly with the slope value and adding the intercept. For example, x=0:1:50 x=2*x plot(x,y) hold % this will hold the plot for you so that you can continue plotting
So, you are next iteration would compute the new linear relation X=50:1:200 y=2/3*x + 200/3 plot(x,y) hold % this will hold the plot for you so that you can continue plotting
[Interpolation may be the word, may be]

Community Treasure Hunt

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

Start Hunting!