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

  Determine the entropy change of nitrogen during this

nitrogen gas is compressed from an initial state of 100kpa and 17c to a final state of 600 kpa and 57c. determine the

  Dtermine the temperature at the turbine exit in degrees f

hydrogen h2 at 2.28 atm and 400 degrees f enters an insulated turbine operating at steady state and expands to 1 atm.

  Bleed steam enters this unit at 3000 kpa with a quality of

feedwater at 4000 kpa is heated at a rate of 6 kgs from 200degc to 245degc in a closed feedwater heater of a

  Systematic approach to solving engineering design problems

Follow a systematic approach to solving engineering design problems-Identify the steps to be followed to move from problem to desired solution(s)

  Belt drive system operates an input speed

A 5v belt drive system operates an input speed of 1250 RPM at the small sheave. The driving sheave has a pitch diameter of 6.000 in, and the driven sheave has a pitch diameter of 19.000 in.

  An essential role in contract management

Post your response (1,000 - 1,250) to the following questions in both the discussion and in the assignment tool.How do senior executives play an essential role in contract management?•Why do senior executives play an essential role in contract manage..

  The following wind conditions are expected v 10 i - 5 j

from time t0 to t5 hr radioactive steam is released from a nuclear power plant located at x -1 mile and y 3 miles.

  A gas within a piston-cylinder assembly undergoes a

a gas within a piston-cylinder assembly undergoes a thermodynamic cylce consisting of three processes. process 1-2

  Although thenbspbuoy normally floats on the surface at

a spherical buoy has a diameter of 1.5 mnbspweighs 8.50 kn and is anchored to the sea floornbspwith a cable as is shown

  Gas turbine are designed to increase the kinetic energy

The stators in a gas turbine are designed to increase the kinetic energy of the gas passing through them adiabatically. Air enters a set of these nossels at 270 psia and 795 F with a velocity of 97 ft/s and exists at 200 psia and 550 F. Calculate the..

  A cylindrical specimen of a brass alloy 100 mm 039 in in

a cylindrical specimen of a brass alloy 10.0 mm 0.39 in. in diameter and 120.0 mm 4.72 in. long is pulled in tension

  The rate of heat flow at the root of the blade

A turbine blade 6.3 cm long with cross-sectional area A 4.6 x 10-4 m2 and perimeter P 0.12 m, is made of stainless steel (k =18 W/m K). The temperature of the root, Ts, is 482°C. The blade is exposed to a hot gas at 871°C and the heat transfer coeffi..

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