I am trying to determine the slope of the best-fit line in log space, and plot the best-fit line as a visual check. It needs to be a line, not a curve (I understand that the misfits could be very large in logspace). Below is an example with xy data and polyfit attempts (and plot included). Thanks for any help
x = [7.94, 16.23, 32.92, 66.8, 135.52, 274.93, 557.78, 1131.59, 2295.72, 4657.46];y = [134000, 102000, 31000, 11000, 2600, 990, 40, 10.41, 3.48, 1.037];scatter(x,y, 'DisplayName', 'MyData')set(gca,'xscale','log')set(gca,'yscale','log')hold ongrid onbox onaxis equalp = polyfit(log10(x), log10(y), 1);z = polyval(p, log10(x));loglog(x, log10(z), 'DisplayName', 'Try1');loglog(x, z, 'DisplayName', 'Try2');z2 = polyval(p, x);loglog(x, z2, 'DisplayName', 'Try3');loglog(x, log10(z2), 'DisplayName', 'Try4');legend
Best Answer