How do I fix this interpolation error
이전 댓글 표시
I am trying to find the exact time constant on the plot but continue to get this error when trying to run the program

댓글 수: 1
Star Strider
2023년 3월 5일
The ‘exprmenttime’ and ‘exprmentresult’ appear to be column vectors, so one optioon could be:
tr = unique([exprmenttime exprmentresult],'rows')
then separate ‘tr’ into the two sorted vectors later.
Similarly,
[tu,idx] = unique(exprmenttime);
exprmentresult = exprmentresult(idx);
could work.
The problem with the ‘desiredY’ assignment is that the interpolation is going to be interpolating ‘expermentresult’ by ‘temptimeconstant’ returning a value for ‘expermenttime’ as the output. I get the impression that you want the result of:
desiredY = interp1(expermenttime, exprmentresult, temptimeconstant);
instead.
However with neither the data nor code text that could be copied, pasted, and run, I cannot determine that.
.
답변 (1개)
Torsten
2023년 3월 5일
0 개 추천
You can only inverse interpolate if your vector "exprmentresult" is strictly increasing or strictly decreasing. Since it contains duplicate values - as the error message from interp1 claims - MATLAB throws an error.
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!