Calculate previous and current values from signal builder

1 view (last 30 days)
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_

Accepted Answer

Fei Deng
Fei Deng on 1 May 2017
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,..]
  1 Comment
siti khadijah
siti khadijah on 8 May 2017
Hai Fei Deng,
Apologizes for responding late. I was away. Thanks for your help :). I'll try this ;)

Sign in to comment.

More Answers (0)

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!