y = sum(x)
x=[1 2 3 5]
is not that true, i am confused.
You haven't stated the *Function* name, input values and output values. Without them the code from the site cannot check your code.
Secondly you've declared X after you wanted to run a function with it.
The program will read:
Sum of X equals Y. X equals Zero or Not a Number, therefore Y is Zero or Not a Number. Next line, X is [Array]. Okay, X is [Array].
Also good practice to end your functions with a semicolon ;
;)
You haven't stated the *Function* name, input values and output values. Without them the code from the site cannot check your code. Secondly you've declared X after you wanted to run a function with it. The program will read: Sum of X equals Y. X equals Zero or Not a Number, therefore Y is Zero or Not a Number. Next line, X is [Array]. Okay, X is [Array]. Y is still 0 or NaN. Also good practice to end your functions with a semicolon ;
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
%%
x = 1;
y_correct = 1;
assert(isequal(vecsum(x),y_correct))
Error: Undefined function 'vecsum' for input arguments of type 'double'.
|
2 | Fail |
%%
x = [1 2 3 5];
y_correct = 11;
assert(isequal(vecsum(x),y_correct))
Error: Undefined function 'vecsum' for input arguments of type 'double'.
|
3 | Fail |
%%
x = [1 2 3 5];
y_correct = 11;
assert(isequal(vecsum(x),y_correct))
Error: Undefined function 'vecsum' for input arguments of type 'double'.
|
4 | Fail |
%%
x = 1:100;
y_correct = 5050;
assert(isequal(vecsum(x),y_correct))
Error: Undefined function 'vecsum' for input arguments of type 'double'.
|
12386 Solvers
Find the sum of the elements in the "second" diagonal
994 Solvers
284 Solvers
365 Solvers
384 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!