Remove the row average (★★★) - MATLAB Cody - MATLAB Central

Problem 45872. Remove the row average (★★★)

Difficulty:Rate

(copy of Prob. 963)

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 ];

Solution Stats

53.57% Correct | 46.43% Incorrect
Last Solution submitted on Jun 27, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
6

Problem Recent Solvers42

Suggested Problems

More from this Author52

Problem Tags

Community Treasure Hunt

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

Start Hunting!