Cody

Problem 742. Symmetric matrix

Solution 520076

Submitted on 3 Nov 2014 by Matthew Eicholtz
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
%% n = 0; A_correct = []; assert(isempty(your_fcn_name(n)))

2   Pass
%% n = 1; A_correct = 1; assert(isequal(your_fcn_name(n),A_correct))

3   Pass
%% n= 3; A_correct =[1.0000 0.5000 0.3333 0.5000 1.0000 0.6667 0.3333 0.6667 1.0000] assert(isequal((your_fcn_name(n)-A_correct<1e-3),ones(n)))

A_correct = 1.0000 0.5000 0.3333 0.5000 1.0000 0.6667 0.3333 0.6667 1.0000

4   Pass
%% n=10 A_correct =[1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.5000 1.0000 0.6667 0.5000 0.4000 0.3333 0.2857 0.2500 0.2222 0.2000 0.3333 0.6667 1.0000 0.7500 0.6000 0.5000 0.4286 0.3750 0.3333 0.3000 0.2500 0.5000 0.7500 1.0000 0.8000 0.6667 0.5714 0.5000 0.4444 0.4000 0.2000 0.4000 0.6000 0.8000 1.0000 0.8333 0.7143 0.6250 0.5556 0.5000 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000 0.8571 0.7500 0.6667 0.6000 0.1429 0.2857 0.4286 0.5714 0.7143 0.8571 1.0000 0.8750 0.7778 0.7000 0.1250 0.2500 0.3750 0.5000 0.6250 0.7500 0.8750 1.0000 0.8889 0.8000 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000 0.9000 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000] assert(isequal((your_fcn_name(n)-A_correct<1e-3),ones(n)))

n = 10 A_correct = Columns 1 through 9 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.5000 1.0000 0.6667 0.5000 0.4000 0.3333 0.2857 0.2500 0.2222 0.3333 0.6667 1.0000 0.7500 0.6000 0.5000 0.4286 0.3750 0.3333 0.2500 0.5000 0.7500 1.0000 0.8000 0.6667 0.5714 0.5000 0.4444 0.2000 0.4000 0.6000 0.8000 1.0000 0.8333 0.7143 0.6250 0.5556 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000 0.8571 0.7500 0.6667 0.1429 0.2857 0.4286 0.5714 0.7143 0.8571 1.0000 0.8750 0.7778 0.1250 0.2500 0.3750 0.5000 0.6250 0.7500 0.8750 1.0000 0.8889 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 Column 10 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000

Suggested Problems

More from this Author30

Community Treasure Hunt

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

Start Hunting!