Question: Write a function in Matlab that takes a 3 digit number as an input and outputs the sum of the each individual digit of the

Write a function in Matlab that takes a 3 digit number as an input and outputs the sum of the each individual digit of the provided input. For ex. If the input is 456 output should

be 4+5+6. The function should work for any 3 digit Number

Use the following format on the first line:

function [sum]=LastName_FirstName(num)

Test your function for: (i)113 (ii535 (iii986 (iv) 283. Copy the command window results showing the function calls and the output and paste this into your function

file as a comment

Hint: try using division on the input combined with the built-in MATLAB function floor() to isolate each individual digit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!