from squared signal to sine form

4 visualizaciones (últimos 30 días)
Sabine Havermans
Sabine Havermans el 6 de Jun. de 2019
Comentada: Sabine Havermans el 9 de Jun. de 2019
I am working on a project with a robot arm. We made a pathplot with an array in matlab and then integrated this in the simulink model with a "from workspace" block. The problem is that the robot will see squared signals as needing to have a infinit high speed. Therefore, the signal should be rounded off a bit. So it has to get to the value that we gave in in the array but i has to go in a normal speed. Is there a simple way to get this done? Or at least another way than adding a lot of little steps in between?
Thanks!
  1 comentario
Adam Danz
Adam Danz el 6 de Jun. de 2019
What are the parameters of the square wave? Are the max and min +/- 1? Is it at a fixed interval? A picture would instantly answer these and other questions.

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 6 de Jun. de 2019
Editada: Adam Danz el 6 de Jun. de 2019
If the parameters of your square wave are known (amp, phase, frequency, shift), you can probably generate the sine wave directly which would be your best bet.
Another approach is to smooth the sine wave with a Gaussian weighted moving average. That can be done with smoothdata() (r2017a or later).
% Produce & plot an arbitrary square wave
x = -4*pi : .01 : 4*pi;
sq = ((sin(2*x+4) >=0) - 0.5) * 4;
plot(x,sq)
ylim([-4,4])
% Smooth it with Gaus moving avg
B = smoothdata(sq,'gaussian');
% Show smoothed curve
hold on
plot(x,B,'r-')
  6 comentarios
Adam Danz
Adam Danz el 7 de Jun. de 2019
Based on the data shared in arrays.m, your arrays are [m-by-2] where the first column are the x values and the second column are the y values. You can apply smoothdata() to the y values like this
sd = smoothdata(arrayq1(:,2),'gaussian');
figure
plot(arrayq1(:,1),arrayq1(:,2),'b-','LineWidth',2)
hold on
plot(arrayq1(:,1), sd, 'r-')
190607 144020-Figure 4.jpg
Sabine Havermans
Sabine Havermans el 9 de Jun. de 2019
Unfortunately, this is not an option, because the robot still needs to reach these outliers. I am going to test with the robot if it is working or not. Thank you for helping!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Signal Processing Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by