Hi Samaneh,
I will abbreviate moment and average_slip as x and y here. Since log log space is evidently the most meaningful representation, the fit should take place using the logs of the y and x variables. You end up with a fit log(y) = a + b*log(x). However, you want to insert this into a loglog plot which is effectively going to take the logs of whatever you input, and then plot. Therefore you have to exponentiate the fit equation. So for the fit line to plot,
yplot = exp(a+b*log(x)) = exp(a)*x^b
This says that a straight line on a loglog plot always has the form y = A*x^b.
The data is pretty scattered so the quality of the fit line is dubious, but there it is.
Going back to the linear fit for the moment, with
you found the fit parameters in the two-component column vector b. To create the best fit line, you don"t have to use b(1) and b(2) as you did. You can just 'undo the backslash', and find the fit line with
average_slip (fit line) = X*b
code
numdata = xlsread('Hayes2017_datasheet.xlsx');
moment = numdata(:,6);
average_slip = numdata(:,13);
X = [ones(length(moment),1) log(moment)];
b = X\log(average_slip);
yCalc2 = X*b;
yCalc2plot = exp(yCalc2);
figure(1)
loglog(moment,average_slip,'o',moment,yCalc2plot,'+-')
0 Comments
Sign in to comment.