Write a function called year2016 that returns a row vector

Assignment Help Mechanical Engineering
Reference no: EM131113344

1. Write a function called year2016 that returns a row-vector of struct-s whose elements correspond to the days of a month in 2016 as specified by the input argument. If the input is not an integer between 1 and 12, the function returns the empty array. Each struct should contain three fields with these (exact) field names: "month", "date", and "day" (all lower case).
• The month field must contain a string with the name of the month (first letter capitalized).
• The date field must contain a scalar specifying the day of the month.
• The day field must contain the three-letter abbreviation of the day chosen from this list: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'.
For example, here is a call of the function followed by a command that shows the seventh element of the struct array that is returned by the function:

2. A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Write a function that is called this way:
>> n = palin_product (dig, lim);
The function returns the largest palindrome smaller than lim that is the product of two dig digit numbers. If no such number exists, the function returns 0. (Inspired by Project Euler.)

3. Each number on telephone keypads, except 0 and 1, corresponds to a set of uppercase letters as shown in this list:
2 ABC, 3 DEF, 4 GHI, 5 JKL, 6 MNO, 7 PQRS, 8 TUV, 9 WXYZ
Hence, a phone-number specification can include uppercase letters and digits. Write a function called dial that takes as its input argument a string of length 16 or less that includes only these characters and returns as its output argument the telephone number as a uint64. Here is the input and output for one example of a call of the function:
Input: '1FUNDOG4YOU'
Output: 13863644968
You can assume that a phone number never starts with 0. If the input contains any illegal characters, the function returns 0. You are not allowed to use the built-in function strrep.

4. An n-by-n square logical matrix can be represented by a cell vector of n elements where the kth element corresponds to the kth row of the matrix. Each element of the cell vector is a row vector of positive integers in increasing order representing the column indexes of the logical true values in the given row of the matrix. All other elements in the given row of the logical matrix are false. Write a function called logiunpack that takes such a cell vector as its only input and returns the corresponding square logical matrix. For example, such a cell vector representation of a 100-by-100 logical matrix with the only true elements at indexes (10, 20) and (10, 75) would have only one non-empty element of the cell vector at index 10. That element is the vector [20 75].
5. Solve the inverse of the previous problem. That is, write a function called logipack that takes a square logical matrix as its only input argument and returns its cell vector representation as specified in the previous assignment. Note that empty array elements of the cell vector corresponding to rows with all false values must have a size of 0x0.

6. Write a function called digit_counter that takes the name of a text file as input and returns the number of digits (i.e., any of the characters, 0-to-9) that the file contains. If there is a problem opening the file, the function returns -1. WARNING: if you use the ‘w' flag with fopen, as opposed to ‘r', you will overwrite the file. The grader uses your own m files to check your function, so be careful!

7. Write a function called day_counter that returns the number of Mondays that fell on the first day of the month in a given year between 1776 and 2016 inclusive where the requested year is the only input to your function and it is a positive integer scalar. Note that a leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. In a leap year, February has 29 days. You are not allowed to use the datenum built-in function. (Inspired by Project Euler.)

8. Write function called huge_add that adds together two positive integers of any length specified as strings using decimal notation. The single output argument is the result and it is a string as well. The inputs and output must contain digits only; no commas, spaces or any other characters are allowed. If any of these assumptions are violated by the input, the function returns the number -1.

9. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. Write a function called smallest_multiple that returns a uint64, the smallest positive number that is evenly divisible by all of the numbers from 1 to n where n is a positive integer scalar and is the only input argument of the function. If the result would be greater than what can be represented as a uint64, the function returns 0. (Inspired by Project Euler.)

Reference no: EM131113344

Questions Cloud

What is the interpretation of your results : Using Exhibit 5.4, calculate the one-, three-, and six-month forward premium or discount for the U.S. dollar versus the British pound using European term quotations. For simplicity, assume each month has 30 days. What is the interpretation of your re..
Discuss any three principles of communication : Take any English newspaper and discuss any three principles of communication with reference to any news item of at least 75 words
Increase the space in linux system : You have just been handed a new IDE hard disk to increase the space in your Linux system. Your goal is to install the IDE hard disk and configure it so it's the master drive on the secondary IDE channel.
Determine the frequency of the stator-induced voltage : The uniform air gap is of length 1 mm, while the armature diameter is 0.5 m, and the axial length of the machine is 1.5 m. The field winding carries a current of 1 A (dc) and the rotor is driven at 3600 r/min.
Write a function called year2016 that returns a row vector : Write a function called year2016 that returns a row-vector of struct-s whose elements correspond to the days of a month in 2016 as specified by the input argument. If the input is not an integer between 1 and 12, the function returns the empty array...
Technology-product review for an siem solution : A client company has asked you to research and recommend a product which will allow them to upgrade or replace their first generation Security Information and Event Management (SIEM) product with a next generation solution that combines real-time ..
Prepare the journal entry to record the reimbursement : Petty Cash The petty cash fund of Teasdale's Auto Repair Service, a sole proprietorship, contains the following. The general ledger account Petty Cash has a balance of $300.
Conduct an industry and competitive analysis : Provide an overview of the companys current performance (in majority of cases this will be financial) - Identify the company's capabilities: using Porter's Value Chain
Micro-programmed control unit : Suppose you wanted to implement a control unit for a computer that you are designing. Would you use a hardwired implementation or a micro-programmed control unit? Why? What factors in the computer design would affect your decision?

Reviews

Write a Review

Mechanical Engineering Questions & Answers

  Consider a cold aluminium canned drink

Consider a cold aluminium canned drink that is initially at a uniform temperature of 3°C. The can is 12.5 cm high and has a diameter of 6 cm. The combined convection/radiation heat transfer coefficient between the can and the surrounding air at 25°C ..

  Fluid flow through a non-circular cross-section pipe

The pipe flow experiment deals with fluid flow through a non-circular cross-section “pipe”. Please explain, using supporting equations, HOW you would calculate the pressure loss during fluid flow between two points along the pipe.

  Calculate the thermodynamic potential of the cell

Calculate the thermodynamic potential of the cell.

  A steel rod with a diameter of 0625 is loaded in tension

a steel rod with a diameter of 0.625 is loaded in tension with 12000 lb load. in the unloaded condition the rod is 240

  Difference between a sensor less esc and sensored esc

What is the difference between a sensor less esc and sensored esc? Which ones can be programmed auto messily and or by controller?

  Why is the carnot cycle not suitable as an ideal cycle

why is the carnot cycle not suitable as an ideal cycle for all the power producing devices ?

  A cylindrical barrel has a narrow tube fixed

A cylindrical barrel has a narrow tube fixed to the top, as shown with dimensions in below figure. The vessel is filled with water to the top of the tube. Calculate the ratio of the hydrostatic force exerted on the bottom of the barrel to the weight ..

  Heat in the amount of 190kj is transferred directly from an

heat in the amount of 190kj is transferred directly from an energy-source at 790k to an energy-sink at 2065k. prove

  A 120 lbm base jumper extreme parachutist leaps from el

a 120 lbm base jumper extreme parachutist leaps from el capitan in yosemite national park 3000 ft vertical drop head

  Diameter pipeline from the boiler to the turbine

In a steam power station, steam flows steadily through a 0.3 m diameter pipeline from the boiler to the turbine. In the boiler, the steam is at 5 MPa and 400 0 C while reaching the turbine it changes to 2 MPa and 3000 C. There is a loss of heat about..

  Express both w and dw/dz as functions of z = x + jy

For these values of a and b find the derivative of w, and express both w and dw/dz as functions of z = x + jy.

  An air-water vapor mixture enters an adiabatic saturator at

an air-water vapor mixture enters an adiabatic saturator at 30 degree c and leave at 20 degree c which is the adiabatic

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd