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
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
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 ExchangeInterpolation についてさらに検索

タグ

質問済み:

2023 年 3 月 5 日

コメント済み:

2023 年 3 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by