Exponential Fit to Data Points in Matlab -
i'm trying fit exponential curve of first order (i'm going make 1 of second order well) data points in matlab. i've been trying use method described in other question here @ stackoverflow message: 'error in ==> fit @ 115 errstr = handleerr('curvefit:fit:xdatamustbecolumnvector', ...'.
this code:
hold on x = (1x8-vector containing data); y = (1x8-vector containing data); error = (1x8-vector containing data); yerror = y.*error; ft = fittype('exp1'); f = fit(x, y,ft); errorbar(x, y, yerror, 'squarek','markerfacecolor','k') plot(f,x,y)
i know 'fit' should return coefficents of exponential curve i'm aware last 'plot' not going work. right can't coefficents out.
a 1x8 vector row vector. 8x1 vector column vector. may seem trivial distinction, have effect on workings of code, fit requires size(x,2) either 1 or 2 (you can see typing edit fit.m @ command line).
granted, error got little opaque. r2011b throws (with correct line numbers ifit , fit):
x must matrix 1 or 2 columns.
just x', y' fix problem (or adjust code produces x , y give column vectors in first place).
Comments
Post a Comment