66 940
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #2038 in MatLAB | Mathematica | MathCAD | Maple for Jayesh

Question #2038
Write a user-defined MATLAB function that takes one single-valued input argument and checks whether the input argument is divisible by 3. If the input argument is divisible by 3, the function should return 1; otherwise, it returns 0.
Expert's answer
Create a file "is_div.m" with the following contents:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [res] = is_div(x)
if (rem(x,3)==0)
res=1;
else
res=0;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Then you can test this function by using the following commands:

>> is_div(45)ans =
1

>> is_div(34)ans =
0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions