how do i interpolate non increasing data

Hello everybody,
I need help to interpolate simulation data. In my case, i have 3 matrixes.
and I need a 3-D interpolation.
X(axis ) is Torque,
Y(axis) is rpm,
and my z(axis is the efficiency).
First, I build a 2-D Dataset from x and y, that works.
Now i need the Datas from z, but z is non strictly monotonically increasing.
I am using griddedinterpolation for x and y with 'spline'.
How can I interpolate my efficiency with non-increasing values.
Kind regards.

3 Comments

Have you tried using interp2?
I need to see your data. Very often, people mistake what kind of interpolation is appropriate for their problem. Best would be if you provide the data itself as a .mat file, attached to a comment. Then I can take the data, look at it, understand what problem you are running into, plot it, rotate the plot, etc.
Not as good is if you simply attach a plot figure. At least let me look at the data in some way.
Without the data? This is hard to know. Why not? Because z being non-monotonic is not relevant. At best, I might guess that you have points in 3-d where the data does not represent a single valued function of the input. Thus, for a single (x,y) pair, you can have TWO distinct z values. For example, suppose your data lies on the surface of an entire sphere in 3-d? Now tools like griddedinterpolant, scatteredInterpolant, griddata, interp2, etc. are all completely unusable.They are not designed to solve that class of problem. But I cannot know what is truly the issue until you show us the data itself.
z does no need to be monotonic. The z values do not affect the failure or success of griddedInterpolant. The x and y values on the other hand do. You have not told us how you're generated the x and y value. Most likely the problem is there, so show us your code.
[torque, speed] = ndgrid(1:100, 100:100:5000); %Nm and rpm
efficiency = rand(size(torque)); %definitively not monotonic
F = griddedInterpolant(torque, speed, efficiency) %NO ERROR!
efficiency vs speed and torque tends to look like an elliptic paraboloid which should work well with griddedInterpolant but as John said, if your surface is special it may not be suitable. If it's spherical I'd say your simulation has failed. In any case, having an idea of what it looks like would indeed be useful.

Sign in to comment.

Answers (1)

Thank you very much for your help.
Your solution works with your given data.
But my data looks like this (see attached picture). Here you see an example of the speed. The torque looks the same but it changes from top to buttom not like the speed form left to right.
I think it has something todo with the NaN or zeros inside these data. How can i solve this. There are 3 of like this like i told speed torque and efficiency. Speed(1,1) and Torque(1,1) gives me the efficiency @Efficiency(1,1).
example.JPG

Categories

Find more on Interpolation in Help Center and File Exchange

Asked:

on 27 Feb 2019

Answered:

on 28 Feb 2019

Community Treasure Hunt

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

Start Hunting!