Trying to package anonymous function + function parameters in a structure
Mostra commenti meno recenti
I assumed this would work but it doesn't:
myStruct.A = 3;
myStruct.B = 7;
myStruct.myFunc = @(x) myStruct.A*x + myStruct.B;
test1 = myStruct.myFunc(1) %Returns 10
myStruct.B = 6;
test2 = myStruct.myFunc(1) %Still returns 10 but i want it to return 9
This is a trivial example but in my actual script the function i am working with it quite complicated; Imagine that this goes from Struct.A to Struct.Z and every one is a vector or matrix. This would get very tedious if I had to write the function with a @(x, A,B,C,..Z).
Looking for recomedations on how to acheive this.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!