function y = your_fcn_name(x)
if (~isinf(x) && fix(x)==x)
y=1
else
y=0
end
end
function y = your_fcn_name(x)
if abs(round(x)-x)==0
y=1;
else
y=0;
end
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
x = 15;
y_correct = 1;
assert(isequal(your_fcn_name(x),y_correct))
ans =
1
|
2 | Pass |
%%
x = 15.25;
y_correct = 0;
assert(isequal(your_fcn_name(x),y_correct))
ans =
0
|
3 | Pass |
%%
x = 10;
y_correct = 1;
assert(isequal(your_fcn_name(x),y_correct))
ans =
1
|
819 Solvers
Matrix indexing with two vectors of indices
485 Solvers
387 Solvers
382 Solvers
359 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!