Hello, friends:
Who can help me with the following issue??
I have a set of (x, y) data. I am going to find the coefficent (a, b) of Y = a*Log(x) +b. I did the following steps:
1. convert x data to Log data.
2. use polyfit to find a, b of Y = a*Log(x)
3. I use polyfit to find a and b.
By using poly(xfit, yift), I can only draw curve of y and log(x), which is a straight line. how to draw the fitting curve of x and y but using the coefficient a and b? Please try to run the following code:
Y = [9,1,2,3,4,5,6,7,8];
X = [0.65,14.84,10.64,7.48,5.40,3.17,1.69,1.45,0.92];
X_Log =[];
for c = 1:length(X),
X_Log = cat(2,X_Log,log(X(c)));
end
[X_Log_Sorted index] = sort(X_Log,'ascend');
Y_Sorted = Y(index);
X_Sorted = X(index);
z = (X_Log_Sorted  mean(X_Log_Sorted))/std(X_Log_Sorted); %for log data
zfit = linspace(z(1), z(end), 9);
[pz] = polyfit(z, Y_Sorted,1) %find the coefficient of y = a*LN(x)
[yfit] = polyval(pz, zfit)
xfit = linspace(X_Sorted(1), X_Sorted(end), 9)
f = figure;
scatter(X_Sorted,Y_Sorted,5,[1 0 1]);
xlabel('X');
ylabel('Y');
title('Calibration Curve');
hold on
plot(xfit,yfit,'bs','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',1);
hold off
Thanks a lot
