How to limit data from a fit?

46 ビュー (過去 30 日間)
Alexandria Will-Cole
Alexandria Will-Cole 2018 年 7 月 24 日
回答済み: Walter Roberson 2018 年 7 月 24 日
I have a custom fit that fits data that I've plotted. I now want to try to limit the range in which the fit occurs. I want it to limit where x is less than 150.
Here is my current code:
rho=Resistivityohmcm;
T=TemperatureK;
plot(T,rho,'-o')
x=T;
y=rho;
fnPolySq=@(p1,p2,x) p1*x.^2 + p2;
fit(x,y,fnPolySq)
plot(f,T,rho)
disp (f)

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 24 日
mask = x < 150;
f = fit(x(mask), y(mask), fnPolySq);
plot(f, T, rho)

その他の回答 (1 件)

Aquatris
Aquatris 2018 年 7 月 24 日
Create new variables;
range = find(x<150);
xNew = x(range)
yNew = y(range)
Obtain your fit using xNew and yNew variables instead of x and y.

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by