Error in interp1 (line 117) extptids = Xq < X(1) | Xq > X(end);

5 views (last 30 days)
error : Index exceeds matrix dimensions.
Error in interp1 (line 117) extptids = Xq < X(1) | Xq > X(end);
Error in get_clk_corr (line 22) err = interp1(sp3.data(jj,sp3.col.TOW),sp3.data(jj,sp3.col.B),tsat,'linear',NaN);
Error in PreciseGPSReceiverPosition (line 113) PRN_obs = get_clk_corr(PRN_obs, sp3);
Input files obs and sp3 are structures. I have copied the structure data into excel and attached here.
  7 Comments
Lakshmi Chodavarapu
Lakshmi Chodavarapu on 28 Aug 2018
Can any one kindly suggest me how to solve this problem. I am still struggling with it. Kindly :(

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 28 Aug 2018
Edited: Stephen23 on 28 Aug 2018
The problem is very simple: the index jj is empty, so you are trying to interpolate empty data (which clearly is impossible: how do you expect to interpolate data that does not exist?).
Why is jj empty? Because the condition you wrote is never true. This is easy to test:
>> index = find(sp3.data(:,sp3.col.PRN)==PRN_obs.data(:,PRN_obs.col.PRN));
>> any(sp3.data(index,sp3.col.B)<1e4)
ans = 0
Because none of the values of sp3.data in the rows give in index are less than 1e4, then jj is empty.
As you have not written any code comments, help, links, or explanation then I have no idea what the solution is: perhaps you have to handle this special case somehow, perhaps your algorithm is flawed, perhaps your code is buggy... in any case, you now know why jj is empty, and how easy this is to check.
Note that your loop to generate jj is very inefficient, because you expand jj within the loop. It is simpler to just use logical indexing:
jj = index(sp3.data(index,sp3.col.B)<1e4)
  2 Comments
Walter Roberson
Walter Roberson on 28 Aug 2018
There are 999999.9999 in bad/absent data points
We recommend you do not look for those using numeric equality. If that key value is above the range of valid values, then test against the valid range, such as sp3.data > 500000 . If there could be valid values with larger magnitude, then test for this particular value using ismembertol() rather than testing for equality: if you test for equality you will miss any values that happen to be one bit off due to floating point representation difficulties.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by