COLORS = ["k" "b" "y" "r" "g" "m" "c"]; % Read in data points S = readtable("simulatedDegradationData.csv", "Delimiter", ",", "ReadVariableNames", true); for n = 1:7 xdata(:,n) = table2array(S((((n-1)*20+1):(n*20)), 3)); xdata(:,n) = xdata(:,n)/max(xdata(:,n)); ydata(:,n) = table2array(S((((n-1)*20+1):(n*20)), 4)); fun = @(x,xdata)x(1)*exp(x(2)*xdata); c0 = [0.1,0.1]; c = lsqcurvefit(fun,c0,xdata(:,n),ydata(:,n)); times = [0:0.02:1]; plot(xdata(:,n),ydata(:,n),'o' + COLORS(n)) hold on plot(times,fun(c,times),'-' + COLORS(n)) xlim([-0.1 1.1]) hold on C(n) = c(1); end legend('Data','Fitted exponential') title('Data and Fitted Curve') grid on %ydataSorted = sort(ydata);