How do I plot only a couple terms with the coefficients from a fit?
조회 수: 1 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2015년 11월 19일
답변: MathWorks Support Team
2015년 11월 19일
I have a model function which consists of many terms. Let GG be the cfit results. Using
feval(GG, xdata)
gives the fit using all the terms. Is it possible to plot only a couple terms, e.g. Term 3 + Term 4, without fitting the model function again?
채택된 답변
MathWorks Support Team
2015년 11월 19일
Yes. The following example plots the linear terms of a polynomial fit of census data.
load census;
GG = fit(cdate,pop,'poly3','normalize','on');
coeff = coeffvalues(GG);
normedData = (cdate - mean(cdate)) / std(cdate); % coefficients were derived in fit with normalized xdata so normalize it to plot
Y = coeff(3)*normedData + coeff(4); % fit using only the linear terms
scatter(normedData, pop);
hold on
plot(normedData, Y); % plot linear terms
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!