Need to check input between range and convert it if not
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sergio Onita
el 27 de Oct. de 2022
Editada: Fangjun Jiang
el 28 de Oct. de 2022
The following subsystem is an error function for a robot which moves in a 2D spaces. So the error is based on the euclidean distance and the orientation error, theta. What I need to do is to check whether theta input is between two values (-pi, pi) and convert it to be in the specified range. For example, 2pi would be a whole circle but since we work on -pi, pi, it would be the same as 0, 3pi would be pi, 3pi/2 would be -pi/2 and so on, This is the subsystem, i have not found any block that could do this so specifying the range in the theta properties as -pi pi is as far as i've gotten.
0 comentarios
Respuesta aceptada
Fangjun Jiang
el 28 de Oct. de 2022
Editada: Fangjun Jiang
el 28 de Oct. de 2022
The best way is to make sure theta is within [-pi, pi]. All trigonometry functions in MATLAB/Simulink has a defined output range. You may just need to add an offset.
If theta is an input and out of your control, you can use the mod(theta, 2*pi) function. It will gave you the output range of [0,2*pi), you will then add an offset to it.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Simulink 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!