سؤال

So I have a long list of data and for my project and I need to find a line of best fit for it. My professor has recommended centering and scaling the data using [p,S,mu] = polyfit(x,n). But then when I compute the best fit line, I should be using this new data. How do I access this data? Matlab's help says that it uses a formula taking (x- mu1)/mu2. So to use the corrected x values I would just need to replace the x in yfit1 = polyval(coef1,x); with (x-mu(1)/mu(2))?

هل كانت مفيدة؟

المحلول

Yes, that is correct. Replace

yfit1 = polyval(coef1,x); 

with

yfit1 = polyval(coef1,(x-mu(1))/mu(2));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top