문제

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