Cody

# Problem 47088. Function Call Counter

Solution 3405743

Submitted on 26 Oct 2020 by Rafael S.T. Vieira
• Size: 46
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
F = @sin; [G,C] = function_call_counter(F); expected = 0; actual = C(); assert(isequal(expected,actual))

2   Pass
N = 500; omega = linspace(0,2*pi,N); rng shuffle K = 5; omega_k = omega(randi([1 500],1,K)); F = @cos; [G,C] = function_call_counter(F); expected = F(omega_k); actual = G(omega_k); expected_count = 1; actual_count = C(); assert(isequal(expected,actual)) assert(isequal(expected_count,actual_count))

3   Pass
F = @sin; [G,C] = function_call_counter(F); K = randi([0 1000],1,1); for k = 1:K G(pi); end expected = K; actual = C(); assert(isequal(expected,actual))

### Community Treasure Hunt

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

Start Hunting!