Effacer les filtres
Effacer les filtres

Arrayfun with Extra Parameters

26 vues (au cours des 30 derniers jours)
Dave O
Dave O le 4 Juil 2024 à 1:30
Commenté : Dave O le 4 Juil 2024 à 11:27
I have a function myfunc(x,y,L,P) designed to take x,y coordinates and additional parameters L(11x2 double) and P(36x1 double). When I test the function, it works properly. When I try to repeat the calculation using a vector of coordinates, arrayfun and an anonymous function, it fails. Hopefully the code snippet below is enough for someone to help me diagnose.
x = 10;
y = 1;
Test1 = myfunc(x,y,L,P); % Works!
f = @(x,y)myfunc(x,y,L,P)
Test2 = f(x,y) % Works - matches above!
a = ones(5,1)*x;
b = ones(5,1)*y;
Test3 = arrayfun(@f,a,b) % Unrecognized function or variable 'f'

Réponse acceptée

Torsten
Torsten le 4 Juil 2024 à 1:35
Test3 = arrayfun(f,a,b)
instead of
Test3 = arrayfun(@f,a,b)
  1 commentaire
Dave O
Dave O le 4 Juil 2024 à 11:27
Well that was easy. Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by