How to apply exponential anonymous function to NxN matrices?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kris Hoffman
am 12 Nov. 2020
Kommentiert: Star Strider
am 12 Nov. 2020
I have 2 NxN matrices (a and b) that I need to perform an operation on. Ideally I'd like to use an anonymous function to compute this elementwise all at once.
So far I have,
syms t
a = rand(32,32);
b = rand(32,32);
Y = @(a,b) a.*exp(-t./b);
Test = integral(Y(a,b),0,3);
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Nov. 2020
The symbolic involvement is not necessary.
Try this:
a = rand(32,32);
b = rand(32,32);
Y = @(a,b,t) a.*exp(-t./b);
Test = integral(@(t)Y(a,b,t),0,3, 'ArrayValued',1);
Tha 'ArrayValued' name-value pair is important here.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!