%The function MyTimeConversion that takes total
minutes as input to the function
%Then find the total number of hours and total number of minutes
for given total minutes
%The result of the function is stored in the Hours, Minutes and
Message values
%Save this below code file as MyTimeConversion.m and run the file with the function name from Matlab as shown in %sample %output
-----------------------------------------------------------------------------------------------------------------
%MyTimeConversion.m
function[Hours, Minutes, Message]
=MyTimeConversion(TotalMinutes)
%Divide TotalMinutes by 60 and get its floor value
%call floor method to get Hours
Hours=floor(TotalMinutes/60);
%call mod method to get Minutes as remainder value
%by dividing the TotalMinutes by 60
Minutes=mod(TotalMinutes,60);
%Concatenate the strings using strcat function
%num2str converts the number to string type
Message=strcat(num2str(TotalMinutes)," minutes are equal to
",num2str(Hours)," hours and ",
num2str(Minutes)," minutes");
end
-----------------------------------------------------------------------------
Sample Output:
>> [Hours, Minutes, Message]
=MyTimeConversion(151)
Hours = 2
Minutes = 31
Message = 151 minutes are equal to 2 hours and 31
minutes
>> [Hours, Minutes, Message]
=MyTimeConversion(120)
Hours = 2
Minutes = 0
Message = 120 minutes are equal to 2 hours and 0
minutes
>> [Hours, Minutes, Message]
=MyTimeConversion(600)
Hours = 10
Minutes = 0
Message = 600 minutes are equal to 10 hours and 0
minutes
use matlab to solve it 1. Write a function called MyTimeConversion with the following function declaration...
(16 minutes) The function below has 4 errors. It has two integer parameters representing the time in hours and minutes. It should add one to the minutes, unless the minutes value is 59, in which case it should set the minutes to 0 and add one to the hours. Changes to either parameter should change the corresponding variable argument from the function call. The function should also calculate the total number of minutes (60 times the hours plus the minutes)...
This basic problem demonstrates the while-loop. (USE MATLAB) Write a Matlab function called steps that takes one scalar as an input argument and returns two scalars as output arguments. If it is called this way [n, d_left] = steps(d), then it sets n equal to the minimum number of steps required to move from a distance of one foot away from a wall to a distance less than d feet from the wall. The first step is 1/2 foot. If...
MATLAB Qla In the fib_clock.m file, write a function file that accepts the hour and minute values, and returns the logical vectors that indicate the appropriate Fibonacci numbers (1, 1, 2, 3, 5] to be used to represent the hours and minutes. Each Fibonacci number can only be used once. The following function file header is provided: function [fib_hour, fib minute] fib_clock(hour,minute) The hour variable needs to be an integer from 1 to 12 and the minute variable needs to...
[MATLAB] Write a function called myMultProd.m that computes the cumulative product of the elements in a vector. The cumulative product, pj, of the jth element of the vector x, xj, is defined by pj = (x1)(x2) … (xj) for j = 1:length of the vector x. DO NOT USE CUMPROD For example, when you run your function it should look like this: >> x = [2 3 4 2]; >> myMultProd(x) >> ans = 2 6 24 48 That is,...
MatLab Help!! Write a function called Difference to calculate the central difference, forward diflerence, and backward diference approximation to an function within a given range of xmin:xinc:xmax The input argument of the function Difference is the handle to an anonymous function, a row array xmin:xinc:xmax The differences should be returned as a row array, calculated at xmin xinc xmax Restriction. The function should not use loops Ex func - (x) x.3 xmin-3 xinc-e.25; xmax-4; [backDifference, centralDifference, forwardDifference] Derivative(func, xmin, xmax,...
Please write in MATLAB code: 1. Write a function called myMin4 that will take in four numbers and returns the minimum value. You may NOT use the built-in min() function. Run the function for the following: myMin4(4, 8, 12, 15) myMin4(18, 9, 1, 6) myMin4(8, -2, 2, 10) 2. Write a function called classAverage that takes in an array of numbers and returns the letter grade of the class average. The grade ranges are as follow: Average >90 = A...
MATLAB code help! Function Name: chemTimer Inputs: 1. (double) The current position of the hour hand 2. (double) The current position of the minute hand 3. (double) A positive or negative number of minutes Outputs: 1. (double) The position of the hour hand after the specified time 2. (double) The position of the minute hand after the specified time Background: Oh no, you were running late to your Chem lab and completely forgot your reaction timer! It's a good thing...
use java and write in text a. Rewrite the following code segment using if statements. Assume that grade has been declared as of type char. char grade= 'B';; switch (grade) { case 'A': System.out.println("Excellent"); break case 'B': System.out.println("Good"); default: System.out.println("you can do better”); } - b. write Java code that inputs an integer and prints each of its digit followed by ** e.gif the integer is 1234 then it should print 1**2**3**4 e.g. if the integer is 85 then it...
i need #6 but i believe #6 function needs to call #5 function. I would like this in C language, and have no pointers, arrays or strings (on function calling and parameters). Thanks! I have attached the other functions that you might need to call for function 6 1. Write and test a function called is_multiple_of that takes a integer n1, integer n2 and determines whether the second argument (n2) is a multiple of the first argument (n1). The function...
matlab 28 pts Question 8 Problem 4. Write the following function. Do NOT hard code using any of the examples. Your function should work for all possible inputs as specified by the problem. Hard coding will result in significant point loss. (B) (28 Points) Function Name: birthday Party Input (2): (char) An Mx 11 array formatted with information about various birthdays (char) An MxN array of names Output (l): (char) A string containing information about the best birthday Function Description:...