trendline option (excel) in matlab -


in excel remember being able select specific trendline termed 'power' according documentation:

'a power trendline curved line best used data sets compare measurements increase @ specific rate — example, acceleration of race car @ one-second intervals. cannot create power trendline if data contains 0 or negative values'.

how can implement in matlab?

for example:

a = [15.5156,0.1995; 7.6003,0.2999; 9.4829,0.2592; 12.2185,0.2239; 23.4094,0.1811];  figure;scatter(a(:,1),a(:,2)) 

here working solution:

a = [15.5156,0.1995; 7.6003,0.2999; 9.4829,0.2592; 12.2185,0.2239; 23.4094,0.1811];  x = a(:, 1); y = a(:, 2); n = 2; % order of fitted polynomial trendline p = polyfit(x, y, n); m = 1000; % number of trendline points (the larger smoother) xx = linspace(min(x), max(x), m); yy = polyval(p, xx);  figure; hold on; scatter(a(:,1), a(:,2)); plot(xx, yy, 'r-'); 

you can put trendline calculator code separate function.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -