Cody

Solution 2121842

Submitted on 8 Feb 2020 by Jiahang Li
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)

v = 0.8165 + 0.0000i 0.8165 + 0.0000i 0.2041 + 0.5401i 0.2041 - 0.5401i d = 1.5000 + 1.3229i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.5000 - 1.3229i ans = -23.0000 + 0.0000i -22.0000 - 0.0000i 11.0000 - 0.0000i -34.0000 + 0.0000i

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)

v = 0.8165 + 0.0000i 0.8165 + 0.0000i 0.2041 + 0.5401i 0.2041 - 0.5401i d = 1.5000 + 1.3229i 0.0000 + 0.0000i 0.0000 + 0.0000i 1.5000 - 1.3229i ans = -0.0532 + 0.0000i -0.0768 - 0.0000i 0.0384 - 0.0000i -0.0915 + 0.0000i

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)

v = -0.5951 + 0.0000i -0.2006 - 0.4586i -0.2006 + 0.4586i -0.7667 + 0.0000i 0.0134 + 0.4280i 0.0134 - 0.4280i -0.2409 + 0.0000i 0.7524 + 0.0000i 0.7524 + 0.0000i d = 4.7907 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -2.3954 + 3.4948i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -2.3954 - 3.4948i ans = 1.0e+03 * 8.3310 - 0.0000i 2.1700 + 0.0000i 2.3800 - 0.0000i 3.7900 + 0.0000i 9.3160 - 0.0000i -0.5350 + 0.0000i -1.2200 - 0.0000i 3.2400 + 0.0000i 4.7910 - 0.0000i

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)

v = -0.5951 + 0.0000i -0.2006 - 0.4586i -0.2006 + 0.4586i -0.7667 + 0.0000i 0.0134 + 0.4280i 0.0134 - 0.4280i -0.2409 + 0.0000i 0.7524 + 0.0000i 0.7524 + 0.0000i d = 4.7907 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -2.3954 + 3.4948i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -2.3954 - 3.4948i ans = -0.0009 + 0.0000i 0.0025 - 0.0000i -0.0009 + 0.0000i 0.0020 - 0.0000i -0.0002 + 0.0000i 0.0017 - 0.0000i 0.0026 + 0.0000i -0.0009 - 0.0000i -0.0016 + 0.0000i