Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('your_fcn_name.m')
assert(~isempty(strfind(filetext, 'gallery')))
assert( isempty(strfind(filetext, '% gallery')))
filetext =
'function y = your_fcn_name(n)
topr = gallery('forsythe',n,0);
topr = topr(:,2:(n+1)/2+1);
topr = topr(1:(n+1)/2,:);
topl = fliplr(topr(:,2:end));
top = [topl';topr']';
bot = flipud(top(1:end-1,:));
y = [top;bot];
end
%This code written by profile_id 1009884
'
|
2 | Pass |
n = 5;
expected = [0 0 1 0 0
0 1 0 1 0
1 0 0 0 1
0 1 0 1 0
0 0 1 0 0];
y_correct = logical(expected)
assert(isequal(your_fcn_name(n),y_correct))
y_correct =
5×5 logical array
0 0 1 0 0
0 1 0 1 0
1 0 0 0 1
0 1 0 1 0
0 0 1 0 0
|
3 | Pass |
n = 9;
expected = [ 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 0
0 0 1 0 0 0 1 0 0
0 1 0 0 0 0 0 1 0
1 0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 1 0
0 0 1 0 0 0 1 0 0
0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 0 0 0]
y_correct = logical(expected)
assert(isequal(your_fcn_name(n),y_correct))
expected =
0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 0
0 0 1 0 0 0 1 0 0
0 1 0 0 0 0 0 1 0
1 0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 1 0
0 0 1 0 0 0 1 0 0
0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 0 0 0
y_correct =
9×9 logical array
0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 0
0 0 1 0 0 0 1 0 0
0 1 0 0 0 0 0 1 0
1 0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 1 0
0 0 1 0 0 0 1 0 0
0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 0 0 0
|
228 Solvers
Find the sum of the elements in the "second" diagonal
994 Solvers
348 Solvers
248 Solvers
Is this triangle right-angled?
2395 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!