how i can compute a signal derivative inside MATLAB function block without extra blocks

3 ビュー (過去 30 日間)
khalil youcefa
khalil youcefa 2016 年 10 月 27 日
編集済み: khalil youcefa 2016 年 10 月 28 日
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:
my question is: How do I get qdot inside MATLAB Function without using any extra blocks (and removing the Derivative block above obviously)?

回答 (1 件)

Swarooph
Swarooph 2016 年 10 月 27 日
  1. I would like to point out the fact that the derivative block has its limitation. Please refer to the documentation page here.
  2. Note from the documentation that, all it does is calculate change in input over change in time. You can do that using a combination of Memory and Clock blocks. Screenshot and code below.
function [y,ydot] = fcn(q,qdel,t,tdel)
y = q; %First output is the input signal itself
delT = t - tdel; % Calculate time interval
delU = q - qdel; % Calculate signal change
if delT > 0 % Check if it is not the first time step
ydot = delU/delT; % Calculate change in input over change in time
else
ydot = 0; % Arbitrarily set derivative to 0 if it is the first time step
end
end
  1 件のコメント
khalil youcefa
khalil youcefa 2016 年 10 月 28 日
編集済み: khalil youcefa 2016 年 10 月 28 日
thank you so much brother, I really appreciate that. your answer its very imoptant and helpful.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by