How to create a lookup table?

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

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.
No the situation is reversed. Based on my rpm I have to provide the torque represented by the red line
What I mean is: My velocity vector to give me that plot shape is not increasing. Since there is a constraint with the lookuptable that the breakpoints must be increasing, how can I solve this problem? Is there any way to implement on simulink considering that my vector is not monotonically increasing?
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.
I solved the problem you mentioned. I isolated in a vector the values of Torque that I need depending on the speed. However, the problem remains when I go to create the lookuptable, because the velocity vector is not increasing.
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.
I thought of creating this model in simulink. I sort the w_OOL data and use the sorted indexes to sort the T_OOL data. So with monotonically ordered vectors I can use the Lookup Table Dynamic block. The vector w_OOL is a vector of rpm ranging in an unordered fashion from 750 to 2479, whereas the vector T_OOL is ordered.
I don't understand why I get this error.
It is as if the sort block does not work. But if I replace the data with a vector xxx=rand(1,200) it works correctly. I don't understand how to get out of this problem. I repeat, I think the problem is between the w_OOL vector and the sort block, but I don't understand what the problem is.
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.
yes there are. But it's normal in order to have that plot.
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.
It is impossible not to have repeated values. If you look at the graph, in the initial vertical part also in the mid-part, the rpm value remains the same but the torque value. This is necessary to have this shape. So I collected in a row vector the rpm values and in another row vector the torque values. So that, plotted point by point, they give me the desired shape.
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?
you're right. how can i solve the problem?
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.

Sign in to comment.

Answers (1)

KSSV
KSSV on 6 Jan 2021
Edited: KSSV on 6 Jan 2021
Read about knnsearch. Also have a look on scatteredInterpolant.

1 Comment

I already have points. The red line is already plotted. I don't understand how to overcome the problem on simulink. Because the error says that the breakpoints (speed values) must be monotonically increasing.

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!