Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function Name: timeUnscrambler Inputs: 1. ( double ) MxN array representing your scrambled time card Outputs: 1. ( double ) Mx(N+1) array representing your fixed

Function Name: timeUnscrambler

Inputs:

1. ( double ) MxN array representing your scrambled time card

Outputs:

1. ( double ) Mx(N+1) array representing your fixed time card

Topics: ( array masking ), ( sorting arrays ), ( linear indexing )

Background:

You've just been hired as a TA for Georgia Tech's newest computer science class,

CS1731. In hopes that the CS department will give you a raise, you decide to take on some

extra hours by working the overnight shift at the help desk. Each night, you log the hours youve

worked on a timecard, and at the end of the week you turn it in to your boss in hopes of that

prized promotion. One evening, however, you fall asleep for 5 minutes on the job and when you

wake up, your pesky co-TA's have messed with your time cards to ruin your chances of

impressing your boss! Desperate, you turn to MATLAB to help you unscramble the mess.

Function Description:

You are given an array of doubles representing your scrambled time card. Apply the

following operations to unscramble your card:

1. Replace all negative numbers in your array with their positive equivalent (i.e. -5 5)

2. Flip the order of the elements in your array's major diagonal, for example:

[ 1 2 3 4 [ 6 2 3 4

5 6 7 8 5 1 7 8

9 0 1 2 9 0 6 2

3 4 5 6 ] 3 4 5 1 ]

3. Sort the rows of your array in ascending order based on the first column (i.e. the

numbers should get larger as you go down the rows in the first column).

4. The first column of your sorted array will represent the amount of time you have worked,

in minutes. Replace this column with two separate columns in the final output, where the

first column is the number of hours you have worked, and the second is the number of

additional minutes. For example:

[ 100 [ 1 40

234 3 54

52 0 52

300 ] 5 0 ]

Homework 05 - Arrays

Example:

scrambled = [ -11 -23 3 -40

8 382 -22 0

-80 -49 123 -2

563 4 4 63 ]

unscrambled = timeUnscrambler(scrambled)

unscrambled = [ 0 8 123 22 0

1 3 23 3 40

1 20 49 382 2

9 23 4 4 11 ]

Hints:

To linearly index out the values of the major diagonal, start by finding the starting index,

step size, and stopping index for the diagonal first.

Try writing out 5x3, 3x3, and 3x5 arrays and ask yourself the following questions:

How do the indices for the major diagonal behave?

What patterns do you observe (either in step sizes or stopping index values) in

relation to the arrays dimensions?

How can you flip or reverse the order of a vector using linear indexing?

Please solve using matlab!! To receive a thumbs up on question DO NOT USE Condtional Statements(if,else,elseif) or Iterations(loops) on this problem.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions