griddedInterpolant Error: Apparent Contradiction
显示 更早的评论
I have some code that uses griddedInterpolant, and it runs fine for the most part. However, there is the rare case where it spits out the error
"Not enough input arguments"
or
"Index in position 1 is invalid. Array indices must be positive integers or logical values."
I thought "that's strange, I'd better check that the inputs are sensible," so I set up my code to throw an error report with a list of the input values. I then re-inserted those input values into my griddedInterpolant, and it didn't throw an error! I have absolutely no idea what's going on - the gridded interpolant works for the values that cause it to throw an error!?
Have you ever seen griddedInterpolant throw these errors before? What was the remedy?
4 个评论
Walter Roberson
2021-1-31
The index error implies that in that context it thinks griddedInterpolant is a variable. If your debugging is a different workspace it might not look a variable there.
David Cyncynates
2021-1-31
John D'Errico
2021-1-31
New users seem to get stuck in these things. They do something without really realizing what variables or functions they have created. Then they get strange errors. Nothing makes sense. They jump to conclusions that something strange happened, when it was something they did to create the problem. I'm sorry, but we see this happen all the time.
The answer is to be more careful, to know exactly what is in your variables, to know what shape they are, etc. Are you running with the debugger turned on? If so, then if you just had an error, then you will be stuck in the wrong workspace.
The fact is, what you are seeing is not normal behavior. I (and many others) have used griddedInterpolant an uncounted number of times. If you are getting this sort of thing happening, it is something you did without knowing what you did. So go more slowly. Make sure after every step that what you just did is what you expected it to be. Ensure that your variables contain what you think they should. Make sure that if you have an error with the debugger turned on, after you resolve it, that you reset the debugger to drop you back into the base workspace!
David Cyncynates
2021-1-31
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!