Using accumarray with nested inline function

Hi
I have below data and would like to use accumarray to perform calculation with inline functions
locOut = @(x) matches( x,"Gross", 'Ignorecase',true); % identifying rows for Gross data
NetCalc= @( flag, loss) ( loss( locOut(flag)) - sum( loss(~locOut(flag))));
Calculating Net Loss = Gross - sum( other rows)
[ uniqLayer,~,JGrp] = unique( LayerId));
final = accumarray( JGrp, loss, [], @PRA_GetNetLoss( flag, loss) ); % Not working
flag = {'xIGW','Gross','QS','BH','Fac','QS2', 'Gross','BH'}';
loss = [1 2 3 6 5 6 10 20];
layerID = [ 111 111 111 111 111 111 222 222]

 채택된 답변

Steven Lord
Steven Lord 2021년 5월 25일

0 개 추천

@PRA_GetNetLoss( flag, loss)
This is not syntacticallly valid in MATLAB. Make this an anonymous function like you did with locOut and NetCalc.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2021년 5월 24일

답변:

2021년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by