is there a command similar to map() that you can use in Matlab
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
good morning , I would like to know if the Arduino IDE has a second command map(val, 0, 1023, 0, 255); where we can read a potentiometer placed on one of the Arduino's analog ports and apply a pwm value to one of the pwm outputs of the arduino uno.
In Matlab is there anything similar to this command, can anyone tell me?
I am doing the communication from the Arduino via Matlab only and for that I downloaded some support packages for Matlab to communicate with the Arduino, so I don't need the (Arduino IDE) to program.
In these packages there are some examples, but for what I want there are not, so I wanted to know if there is any other command that is similar to the one used in Arduino to be used in Matlab without the need to use the Arduino IDE only Matlab
0 comentarios
Respuestas (2)
Stephen23
el 1 de Mayo de 2023
"In Matlab is there anything similar to this command, can anyone tell me?"
MAP is just a very basic kind of interpolation. MATLAB has many interpolation routines:
For example, using the first MAP example:
x = 2;
y = interp1([1,50],[50,1],x)
Note that MATLAB's interpolation routines all operate and return floating point numbers. The MAP documentation specifically states that it performs integer arithmetic: so user beware!
Also note that the MAP documentation gives the formula under "Appendix". That formula is also trivial to implement as very basic MATLAB code, again using the same example:
in_min = 1;
in_max = 50;
out_min = 50;
out_max = 1;
out = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
Making that more MATLAB-y (e.g. to work on vectors) is left as an exercise for the reader.
0 comentarios
Ver también
Categorías
Más información sobre Instrument Control Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!