Please Help I have already run this code in matlab but still get wrong here
If Anybody can help me i strongly grateful to him
Could fail the last test, if A has only 1 column:
c = 1
Bad indexing (r,c-1) == (r,0)
You got to catch case c = 1 and don't swap at all
And................ obviosly
"Undefined function or variable 'C1'."
You have made assignments in wrong order.
Your code says: A(:,1)=C1
Should say: C1 = A(:,1);
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
A = [ 12 4 7
5 1 4];
B_correct = [ 7 4 12
4 1 5 ];
assert(isequal(swap_ends(A),B_correct))
r =
2
c =
3
|
2 | Fail |
A = [ 12 7
5 4];
B_correct = [ 7 12
4 5 ];
assert(isequal(swap_ends(A),B_correct))
r =
2
c =
2
|
3 | Fail |
A = [ 1 5 0 2 3 ];
B_correct = [ 3 5 0 2 1 ];
assert(isequal(swap_ends(A),B_correct))
r =
1
c =
5
|
4 | Fail |
A = 1;
B_correct = 1;
assert(isequal(swap_ends(A),B_correct))
r =
1
c =
1
|
Remove all the words that end with "ain"
1292 Solvers
All your base are belong to us
463 Solvers
Back to basics 23 - Triangular matrix
634 Solvers
1425 Solvers
Find the maximum number of decimal places in a set of numbers
735 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!