how to use anonymous functions

8 visualizaciones (últimos 30 días)
Derrick Salmon
Derrick Salmon el 23 de Feb. de 2018
Respondida: Derrick Salmon el 23 de Feb. de 2018
How do I use an anonymous function
I've set the following:
x = 1:100
a = [1,5,2.5]
gau = @(x)@(x)(a(1).*exp(-0.5.*((x-a(2)).^2./a(3).^2)))
this works fine. but now I want to pass the 'a' parameters, so tried
c = @(g) (@(x),a), but this does not work
Ideas?

Respuestas (2)

Jeff Miller
Jeff Miller el 23 de Feb. de 2018
x = 1:100;
a = [1,5,2.5];
gau = @(x,a)(a(1).*exp(-0.5.*((x-a(2)).^2./a(3).^2)));
m1 = gau(x,a)

Derrick Salmon
Derrick Salmon el 23 de Feb. de 2018
Ahh - works perfectly - thanks for the help

Categorías

Más información sobre Control System Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by