Create a matrix from a curve
Mostrar comentarios más antiguos
I am trying to create a 2D Lookup Table from a curve.
I have this curve that is the basis for a transmission control unit of an electric vehicle. The inputs are torque and rotational speed.

When the current input is left or under the curve, the output shall be zero, otherwise two. I created a matrix manually, that I am using in a lookup table, which you can find attached. This works fine but to create similiar matrices I would like an easier and better way.
Any help is greatly appreciated!
Luke
5 comentarios
Stephen23
el 8 de Mzo. de 2017
How is the "polynomial curve" specified in MATLAB? what kind of variable is it stored in?
Your example A is a vector: in your question you state that you want a matrix. Which do you want?
Luke Crouch
el 8 de Mzo. de 2017
John D'Errico
el 8 de Mzo. de 2017
This question is totally confusing on many levels, a difficult thing to do in such a short question. So you need to explain clearly what you need and what you have.
You state that you have a polynomial curve. In what form is this curve? We are not shown any polynomial. Only a picture with one curved segment. How is the polynomial stored? What form does it take?
The curve that you show has actually linear segments in it that horizontal or vertical. So the curve that you have drawn is not truly a polynomial, since a polynomial is defined over the entire real line. So is this "curve" really a piecewise thing representing a boundary of some sort?
Next, you talk about things like "to the left of the curve" but since part of the curve appears to be horizontal, what do you really mean?
You talk about needing a 2-d lookup table. But the vector A that you show is a VECTOR. In any terminology that I know of, a 2-d lookup table indicates something that has TWO independent variables, so an approximation to a function of the form z(x,y). Here x and y are independent variables, z a third variable, predicted by TWO independent variables.
You talk about a code example. WHERE?????? All you have shown is a vector that contains a lot of elements that are either 0 or 2. The problem is, in your words: "So the matrix I am trying to create has zeros and ones in it..." So is it 1 or 2? Is it a vector or a matrix? A vector in this context is a long string of numbers, a one dimensional thing. A matrix has TWO dimensions. Which is it? What do you really need?
So, SLOW DOWN. Explain what you need very clearly. Using more words where necessary is not a bad thing. If you have code, then show it. Remember, we know nothing about your problem except what you write and the pictures that you have drawn. Use standard mathematical terms. Be consistent. As otherwise, you sow seeds of confusion when we try to answer your question, when we try to figure out what you really mean.
John D'Errico
el 8 de Mzo. de 2017
Editada: John D'Errico
el 8 de Mzo. de 2017
Why would you save it as a text file? Save it as a .mat file, then we can just load it in. I've now done that for you, as a .mat file attached to this comment.
Luke Crouch
el 8 de Mzo. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
