필터 지우기
필터 지우기

Find value of second dependent variable corresponding to new value of independent variable based on defined array

조회 수: 2 (최근 30일)
I have set of array with independent variable 'X' and dependent variable 'Y'. I want to find value of 'Y'given new value of 'X'. i.e. X=normrand(0,1,100,1); Y=1+0.2*X; % it can be any unknown relationship. Equation is written just for example Find value of Y for X=[0.001 1.89 -0.45 1.12]? Thanks

채택된 답변

Stephen23
Stephen23 2016년 9월 13일
편집: Stephen23 2016년 9월 13일
This is exactly what interp1 does:
X = normrnd(0,1,10,1)
Y = 1+0.2*X
% sort:
[Xs,idx] = sort(X);
Ys = Y(idx);
% interpolate:
Xo = [0.001,1.89,-0.45,1.12];
Yo = interp1(X,Y,Xo)
Note that you will need to explicitly specify the behavior if you want it to extrapolate as well as interpolate. You can also choose the interpolation method. Read the documentation to know more.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by