Cody

Problem 42591. Produce the following matrix

Solution 733057

Submitted on 10 Sep 2015 by goc3
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('matrixManipulation.m'); assert(isempty(strfind(filetext, 'system')))

2   Pass
%% x = 1; y_correct = ones(2); assert(isequal(matrixManipulation(x),y_correct))

b = 0 1 0 0 b = 0 0 1 0 y = 1 1 1 1

3   Pass
%% x = 2; y_correct = [1 1/2; 2 1]; assert(isequal(matrixManipulation(x),y_correct))

b = 0 1 0 0 b = 0 0 2 0 y = 1.0000 0.5000 2.0000 1.0000

4   Pass
%% x = 2:4; y_correct = [1 1/2 1/3; 2 1 1/4; 3 4 1]; assert(isequal(matrixManipulation(x),y_correct))

b = 0 1 1 0 0 1 0 0 0 b = 0 0 0 2 0 0 3 4 0 y = 1.0000 0.5000 0.3333 2.0000 1.0000 0.2500 3.0000 4.0000 1.0000

5   Pass
%% x = 2:7; y_correct = [1 1/2 1/3 1/4; 2 1 1/5 1/6; 3 5 1 1/7; 4 6 7 1]; assert(isequal(matrixManipulation(x),y_correct))

b = 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 b = 0 0 0 0 2 0 0 0 3 5 0 0 4 6 7 0 y = 1.0000 0.5000 0.3333 0.2500 2.0000 1.0000 0.2000 0.1667 3.0000 5.0000 1.0000 0.1429 4.0000 6.0000 7.0000 1.0000

Suggested Problems

More from this Author68

Community Treasure Hunt

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

Start Hunting!