Given a 2-d matrix, remove the row average from each row. Your solution MUST be vectorized. The solution will be tested for accuracy AND speed. Any for loops will make the solution too slow to pass the speed test.
Example:
a = [ 1 2 ; 3 5 ]; b = remove_average_vectorized(a); % b is [ -0.5 0.5 ; -1 1 ];
Please modify the fourth test suite so it reports the duration when the assert fails. My tests say I should pass but Cody is exceeding the time. The method to output information on a failed assert is: assert(duration,duration));
thx
The other thing to do is to remove the ";" from the duration=toc(timer) line. This will allow everyone to see how fast the successful routines take to execute. My self-test times are < 500msec but I don't know Cody's speed. thx
Thanks Richard, your suggestions have been implemented.
I am hoping to stimulate a change to cody where some problems (or all) problems are graded on performance not size. A low size often means an unreadable solution, and people have found enough tricks to make size an irrelevance, anyway.
As per Solution 1539945, the Test Suite has been corrupted for me. For me the first line of the Test Suite appears to read "%%x = [ 0 1 ; 2 3 ] ;", and the correct inputs are not supplied. This may be the same Cody bug that previously affected Problem 970 (& perhaps Problem 1319) and still affects Problem 753.
Timing aspect is neat.
Not sure why this is not passing, I've tested time and it completes under 1 second... Anyone have any ideas?
I'm getting the error "While evaluating the solution, the server encountered an error caused by temporary unavailability of MATLAB Service. Wait a few minutes for the MATLAB Service to return, and then rescore." but have been able to submit other answers so I assuming it is not passing?
By vectorized he means y=[..... ] ? Or is it just bugged so this is futile?
There is a serious problem with the Test Suite for this submission to pass!!! —DIV
26–27 May 2018: 2L. Time used = 1.115 seconds in last test case.
See Problem 44655. https://www.mathworks.com/matlabcentral/cody/problems/44655
Consistently, reproducibly getting the following error, "While evaluating the solution, the server encountered an error caused by temporary unavailability of MATLAB Service. Wait a few minutes for the MATLAB Service to return, and then rescore." only for certain array assignments to variable y. See submission code. —DIV
Test Suite has been corrupted. Output from my code is merely echoing the input in each case, which doesn't match the intended input.
20 Sep 2017: 2L. Time used = 2.040 seconds in last test case.
tic toc hack :)
The MATLAB service for this has been unavailable for the past couple of days.
03 Mar 2017: 2L. Time used = 2.341 seconds in last test case.
31 Mar 2016: 2L. Time used = 1.436 seconds in last test case.
17 Apr 2015: 2L. Time used = 3.099 seconds in last test case.
09 Jul 2013 : 2L. Time used = 4.112 seconds in last test case.
29 Dec 2012: 2L. Time used = 4.740 seconds in last test case.
6 Oct 2012: 1L. Time used = 1.226 seconds in last test case.
Fuzzy Logic Toolbox is required for this functioon?
I have it on my System Identification toolbox. There is no clear rule what toolbox functions are admissible. If it works, I guess it is allowed.
02 Oct 2012: 0L. Time used = 0.2666 seconds in last test case.
Thanks, I was unaware of 'detrend'.
How come this fails the first time? Are you just on the limits of the time threshold?
This is almost exactly the same as my 'reference' solution. But later some other people came up with cleaner solutions...
276 Solvers
Project Euler: Problem 7, Nth prime
339 Solvers
Piecewise linear interpolation
136 Solvers
Test if two numbers have the same digits
154 Solvers
313 Solvers