1

I am feeding a signal q into a MATLAB Function block - for example a sinusoid (it could be something else too). My MATLAB Function block also needs the time derivative of the signal. In Simulink I can do something like this:

enter image description here

However I'd like to forego the Derivative block (to conserve space, my actual model is much bigger than the above) and somehow get the derivative directly inside the MATLAB Function. For this I'd need to know the previous value of q probably... which I can't know without adding a memory block.

Question : How do I get qdot inside MATLAB Function without using any extra blocks (and removing the Derivative block above obviously)?

Thanks for your help!

8
  • 1
    Do you mean that you want to 'manually' calculate numerical derivatives inside the Matlab block based on delayed values of q? Bad idea. Commented Sep 15, 2015 at 15:49
  • No, I want to avoid that too. I just want to know if there is a magic option somewhere to pass in the derivative of a signal to the MATLAB Function block without having to place a Derivative block into the diagram. Commented Sep 15, 2015 at 15:50
  • You could use a mux and put the derivative and signal generator in a subsystem to save space. Commented Sep 15, 2015 at 15:52
  • What is the input q? Can you calculate an analytical derivative of it? There is no "magic." If you need the derivative then you need to calculate the derivative one way or another. Commented Sep 15, 2015 at 15:55
  • 1
    For as far as I know, there is no such thing. Use proper signal routing by using (de)muxers, (bus) selectors/creators and subsystems to deal with space problems. Commented Sep 15, 2015 at 16:03

1 Answer 1

0

I'm not sure if you can solve it inside the function block, since you need to know the previous values of q, but maybe you can solve this by using a feedback with delay in which you will return the old value of q, like on the image below.

OldQ with delay.

I don't know if this will solve your problem, but it's worth the try. If you use it in this way, you might want to test the entire model a bit (concerning synchronization of sample times and delays and similar things).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.