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

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 commentaires

Stephen23
Stephen23 le 6 Août 2018
"I have copied the structure data into excel and attached here."
This is basically useless to us. Please upload the original structures in a .mat file.
now attached the input mat files
Your first input is empty when you call the function.
Not able to understand how the first input is empty when there are input files...can you help me to understand where and how it happens, kindly
Stephen23
Stephen23 le 7 Août 2018
Modifié(e) : Stephen23 le 7 Août 2018
@Lakshmi Chodavarapu: we don't have the input argument PRN_obs for function get_clk_corr.
"Not able to understand how the first input is empty when there are input files"
However in reality you have a bug and an error occurs. Code does not care what you understand / think / believe / assure / wish / want / .... If you want to find out why your code is not working, then you will have to:
  • accept that there is a problem, possibly with the data or the input files.
  • start debugging your code: use the debugging tools to view the variables just before the error occurs: what size does it have? Set breakpoint/s to stop then code when that variable is empty/has wrong values/.... Work your way backwards until you understand when the error occurs and why.
Thank you so much Mr.Stephen Cobeldick and Mr.Walter Roberson. I am learning MATLAB myself (of course with the help of internet resources) while using it. Grateful to you for your valuable suggestions and surely will follow.
Can any one kindly suggest me how to solve this problem. I am still struggling with it. Kindly :(

Connectez-vous pour commenter.

 Réponse acceptée

Stephen23
Stephen23 le 28 Août 2018
Modifié(e) : Stephen23 le 28 Août 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 commentaires

You saved my life Sir, I am grateful to you. Learned a lot! There are 999999.9999 in bad/absent data points for which the condition is failing. I am really grateful to you for teaching me how to investigate this error. Thanks again with great gratitude.
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by