Cody

# Problem 1830. Matrix rotation as per given angle

Solution 326828

Submitted on 1 Oct 2013 by Julien
• Size: 11
• 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
%% x= [1 2 3; 4 5 6; 7 8 9] angle = 90; y_correct =[3 6 9; 2 5 8; 1 4 7]; assert(isequal(RotateMat(x,angle),y_correct))

x = 1 2 3 4 5 6 7 8 9 y = 3 6 9 2 5 8 1 4 7 ans = []

2   Pass
%% x = [ 1 2 3 4; -10 -20 -30 -40] angle = 270; y_correct =[ -10 1; -20 2; -30 3; -40 4]; assert(isequal(RotateMat(x,angle),y_correct))

x = 1 2 3 4 -10 -20 -30 -40 y = -10 1 -20 2 -30 3 -40 4 ans = []

3   Pass
%% x = [ 1 2; 3 4; 5 6; 7 8] angle = -90; y_correct =[ 7 5 3 1;8 6 4 2]; assert(isequal(RotateMat(x,angle),y_correct))

x = 1 2 3 4 5 6 7 8 y = 7 5 3 1 8 6 4 2 ans = []

4   Pass
%% x = [ 89 -100 88 -101]; angle = 180; y_correct =[ -101 88 -100 89]; assert(isequal(RotateMat(x,angle),y_correct))

y = -101 88 -100 89 ans = []

### Community Treasure Hunt

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

Start Hunting!