Calculate previous and current values from signal builder

2 次查看(过去 30 天)
Hai guys,
I need your advice as well as help. I use signal builder as an input the matlab function in simulink, and I used the matlab function to calculate the inverse kinematics of my system. The problem now is, I need to calculate difference of the previous and current values from the inverse kinematics.
For instance, 3 values are sent from signal builder : 0, 30 and 70. These values will be recalculated in the inverse kinematics and I set them as 'theta'. And the next thing that I want to do is to calculate : 30 - 0 = 30; 70 - 30 = 40;
But I dont have any idea to do that since the input is in signal builder. Hope any of you could helps or advice me on this matter. Thanks
-CT_

采纳的回答

Fei Deng
Fei Deng 2017-5-1
There are two ways to do it.
1. In the MATLAB function block you write:
function y = fcn(u1,u2)
y = u1-u2;
feed the signal from "signal builder" to u1 (input of MATLAB function block), and delay the signal by "Unit delay" block and feed it to u2.
2. if you are only doing subtraction in the MATLAB function, you can use a sum block(+-) instead. feed the signal into "+", and delay it with a "unit delay" and feed it into "-".
note that the step size of your solver need to be adjusted to the time difference for data [0, 30, 70,..]

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by