MATLAB Answers


Matlab, how to create non linear curve from random data?

Asked by uncung fgv on 22 Apr 2012
example i have data
x=linspace(4,6,7) %data x from 4 until 6 with 7 elements
i will create hiperbolik data or non linear randomly in matlab


Sign in to comment.

1 Answer

Answer by Walter Roberson
on 22 Apr 2012

curvedegree = 2; %set as desired
coeffs = polyfit(x, y, curvedegree);
plot(x, polyval(coeffs, x)); %plot fitted y


why the plot still liniear?
my data:
>> x=linspace(6.502,6.9,5)
>> y=linspace(63.5,75.39,5)
still linear?
Because you fit a parabola to a line.
Where are the random data you are talking of in the subject line?
What about: y = rand(size(x))?

Sign in to comment.