How to create a lookup table?
Show older comments
I have a velocity vector of 200 columns, and a Torque 200x200 matrix. If I type plot(w_ice,T_ice) I get the red line as the result. I need to create a lookup table that represents this red line. If I enter the lookup table in simulink I get the error that the breakpoint must be motorically increasing. How do I proceed?

14 Comments
Athrey Ranjith Krishnanunni
on 6 Jan 2021
It looks as if you need a lookup table that outputs the rpm at the queried torque. In that case, torque is monotonically increasing from 0 to 350 Nm, and the rpm is a function of the torque.
Most likely, the table you had created had these values interchanged, i.e. you had tried to output torque at the queried rpm, hence the "monotonically increasing" error.
You can check this by opening the variables that represent the torque and rpm from the Workspace Explorer.
SIMONE PARENTELA
on 6 Jan 2021
SIMONE PARENTELA
on 6 Jan 2021
Athrey Ranjith Krishnanunni
on 6 Jan 2021
In that case, you have a conceptual issue.
Suppose you have an input rpm of 2500. What output value do you want the lookup table to give? 200 Nm? 225 Nm? 250 Nm? All of these are on the red line, and I doubt that you would be able to choose just one. (And that is exactly why it throws the error.)
This happens because while the rpm is a function of torque (one input value of torque will give only one output value of rpm), the reverse is not true (one input value of rpm will give you multiple output values of torque).
I think you need to solve this larger problem in the physical context of what you are trying to model.
SIMONE PARENTELA
on 6 Jan 2021
Athrey Ranjith Krishnanunni
on 6 Jan 2021
Well, if you have managed to produce unique output values of torque at every input value of rpm, this is fairly easy.
[rpm, sortedIdx] = sort(rpm); % look up documentation for sort
torque = torque(sortedIdx);
Now rpm is monotonically increasing, and the corresponding torque values are also available. You can create a lookup table using them now.
SIMONE PARENTELA
on 6 Jan 2021
Athrey Ranjith Krishnanunni
on 7 Jan 2021
One possibility is that your w_OOL has repeated values. Run
numel(w_OOL) - numel(unique(w_OOL))
to see if there are any repeated entries in w_OOL.
SIMONE PARENTELA
on 7 Jan 2021
Athrey Ranjith Krishnanunni
on 7 Jan 2021
You had said this:
>>I isolated in a vector the values of Torque that I need depending on the speed.
so I thought you had figured out the conceptual problem.
But if you still have repeated points in w_OOL, you haven't solved it yet.
Repeated entries in w_OOL mean that the same input value of w_OOL can correspond to different output values of T_OOL (after sorting, open the variables w_OOL and T_OOL and compare them side-by-side to see this).
This is the same problem that I'd mentioned previously, where the lookup table is unable to choose a single output value from among several equally valid ones.
SIMONE PARENTELA
on 7 Jan 2021
Athrey Ranjith Krishnanunni
on 7 Jan 2021
Exactly, in those regions, rpm (i.e. w_OOL or xdat) doesn't change but torque (i.e. T_OOL or ydat) does. This is a problem when you put it into a lookup table because it doesn't know which value of torque you want when your rpm is in one of those regions.
Just answer this: if there were no error, and you want to lookup the torque for 2500 RPM, what value should the block return?
SIMONE PARENTELA
on 7 Jan 2021
Athrey Ranjith Krishnanunni
on 7 Jan 2021
There isn't enough information to provide a definite answer for that, because the issue is physical and not related to programming.
You could try explaining what you are actually trying to do here in the general sense, and maybe someone who knows about the topic can help.
Answers (1)
Read about knnsearch. Also have a look on scatteredInterpolant.
1 Comment
SIMONE PARENTELA
on 6 Jan 2021
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
