How to apply exponential anonymous function to NxN matrices?
조회 수: 4 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2020년 11월 12일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!