How to generate this function in Simulink (Matlab code):
20.*t.*heaviside(t) - 40.*(t-10).*heaviside(t-10) + 20.*(t-(680)).*heaviside((t-(680)));

 Réponse acceptée

Walter Roberson
Walter Roberson le 8 Fév 2021

0 votes

If you are in a MATLAB Function Block then
heaviside = @(x) x >= 0;

2 commentaires

function y = fcn(t)
y = zeros(size(t));
heaviside = @(x) x >= 0;
y = 20.*t.*heaviside(t) - 40.*(t-10).*heaviside(t-10) + 20.*(t-(680)).*heaviside((t-(680)));
end
Marko Boskovic
Marko Boskovic le 8 Fév 2021
Thank you Walter!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur General Applications dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by