Add parameter (factor) to function

6 vues (au cours des 30 derniers jours)
MrBanana
MrBanana le 5 Déc 2020
Commenté : MrBanana le 5 Déc 2020
Hey everyone,
I have the following two calculations:
f = @(t) pi * sin(pi*t/4) - pi/2;
g = @(t) cos(t);
I simply want to multiply g with f:
@(t) pi * sin(pi*t/4) - pi/2 * cos(t)
Is there any possibility to do this?
I am using MATLAB R2020b.
Thanks in advance!

Réponse acceptée

John D'Errico
John D'Errico le 5 Déc 2020
h = @(t) g(t).*f(t);
The .* operator was used to make it vectorized.
  1 commentaire
MrBanana
MrBanana le 5 Déc 2020
Worked, thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by