Cody

Solution 569534

Submitted on 29 Jan 2015 by Gergely Patay
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
%% filetext = fileread('matpow.m'); assert(isempty(strfind(filetext, '^'))) assert(isempty(strfind(filetext, 'mpower')))

2   Pass
%% x=[1 2; -1 2]; y_correct=x^5; y=matpow(x,5); assert(max(abs(y(:)-y_correct(:)))<1e-5)

ans = -23.0000 -22.0000 11.0000 -34.0000

3   Pass
%% x=[1 2; -1 2]; y_correct=x^-3.5; y=matpow(x,-3.5); assert(max(abs(y(:)-y_correct(:)))<1e-5)

ans = -0.0532 -0.0768 0.0384 -0.0915

4   Pass
%% x=[1 2 3; 4 2 -1; -2 4 -3]; y_correct=x^6; y=matpow(x,6); assert(max(abs(y(:)-y_correct(:)))<1e-5)

ans = 1.0e+03 * 8.3310 2.1700 2.3800 3.7900 9.3160 -0.5350 -1.2200 3.2400 4.7910

5   Pass
%% x=[1 2 3; 4 2 -1; -2 4 -3]; y_correct=x^-4; y=matpow(x,-4); assert(max(abs(y(:)-y_correct(:)))<1e-5)

ans = -0.0009 0.0025 -0.0009 0.0020 -0.0002 0.0017 0.0026 -0.0009 -0.0016