100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Introduction to Programming with MATLAB - Coursera All Assignments & Quiz Answer

Beoordeling
5.0
(1)
Verkocht
3
Pagina's
54
Cijfer
A+
Geüpload op
13-12-2020
Geschreven in
2020/2021

MATLAB as a Calculator - Output end_loan_of_first_year = 1100 new_interest = 110 We borrowed $1000 at a 10% annual interest rate. If we did not make a payment for two years, and assuming th Assign the result to a variable called debt. Lesson 1 Wrap-up 1. As of early 2018, Usain Bolt holds the world record in the men's 100-meter dash. It is 9.58 seconds. Wh called hundred. 2. Kenyan Eliud Kipchoge set a new world record for men of 2:01:39 on September 16, 2018. Assign his a distance is 42.195 kilometers. Colon Operator Practice Output odds = Columns 1 through 30 1 3 5 7 Columns 31 through 50 1. Create a vector of all the odd positive integers smaller than 100 in increasing order and save it into varia 2. Create a vector of all the even positive integers smaller than or equal to 100 in decreasing order and sale. Matrix Indexing Practice Output v = 2 7 12 17 A = Given matrix A, assign the second column of A to a variable v. Afterwards change each element of the last row Matrix Arithmetic Output x = 1 1 1 1 y = Given a Matrix A, Create a row vector of 1's that has same number of elements as A has rows. Create a column vector of 1's that has the same number of elements as A has columns. Using matrix multiplication, assign the product of the row vector, the matrix A, and the column vector (in A Simple Function Write a function called tri_area that returns the area of a triangle with base b and height h, where b and h are in Corner Case Write a function called corners that takes a matrix as an input argument and returns four outputs: the elements and bottom_right. (Note that loops and if-statements are neither necessary nor allowed as we have not covered >> [a, b, c, d] = corners([1 2; 3 4]) a = 1 b = 2 c = 3 d = 4 Taxi Fare Write a function called taxi_fare that computes the fare of a taxi ride. It takes two inputs: the distance in kilomete calculated like this: the first km is $5 every additional km is $2 and every minute of waiting is $0.25. Once a km is started, it counts as a whole (Hint: consider the ceil built-in function). The same rule applies to wa necessarily integers. The function returns the fare in dollars. For example, a 3.5-km ride with 2.25 minutes of wa necessary nor allowed. Minimum and Maximum Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector containing minimum valued elements in each row. As a second output argument called mmm, it provides the difference bet the code below for an example: >> A = randi(100,3,4) A = 66 4 >> [x, y] = minimax(A) x = 76 67 81 y = 90 Matrix Construction Write a function called trio that takes two positive integer inputs n and m. The function returns a 3n-by-m matrix middle third is all 2-s while the bottom third is all 3-s. For an example,see the code below: M = trio(2,4) M = 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 Practice if-statements Write a function called picker that takes three input arguments called condition, in1 and in2 in this order. The a value of in1 to the output argument out, otherwise, it assigns the value of in2 to out. See the examples below t More Practice Write a function called eligible that helps the admission officer of the Graduate School of Vanderbilt University d scores. The function takes two positive scalars called v and q as input and returns the logical admit as output. T portions of the GRE respectively. You do not need to check the inputs. The applicant is eligible if the average pe over 88%. The function returns logical true or false value. Variable Number of Input Arguments Write a function called under_age that takes two positive integer scalar arguments: 1. age that represents someone's age, and 2. limit that represents an age limit. The function returns true if the person is younger than the age limit. If the second argument, limit, is not provide positive integer scalars. The name of the output argument is too_young. Lesson 5 Wrap-up Write a function called valid_date that takes three positive integer scalar inputs year, month, day. If these three name of the output argument is valid. If any of the inputs is not a positive integer scalar, return false as well. No except for years that are exactly divisible by 100. However, years that are exactly divisible by 400 are also leap y 2000 was. Note that your solution must not contain any of the date related built-in MATLAB functions Practice for-loops Write a function called halfsum that takes as input a matrix and computes the sum of its elements that are in the set of those elements whose column and row indexes are the same. In other words, the function adds up the ele output argument is summa. For example, with the matrix below as input Practice while-loops Write a function called next_prime that takes a scalar positive integer input n. Use a while-loop to find and retur use the built-in isprime function. Here are some example runs: Logical Arrays Practice Write a function called freezing that takes a vector of numbers that correspond to daily low temperatures in Fah temperatures (that is, lower than 32 F) without using loops. Here is an example run: numfreeze = freezing([ 12]) Lesson 6 Wrap-up Write a function called max_sum that takes v, a row vector of numbers, and n, a positive integer as inputs. The is the largest possible. In other words, if v is [1 2 3 4 5 4 3 2 1] and n is 3, it will find 4 5 and 4 because their sum such sequences exist in v, max_sum returns the first one. The function returns summa, the sum as the first out consecutive ones as the second output. If the input n is larger than the number of elements of v, the function ret runs: Simple Encryption Caesar's cypher is the simplest encryption algorithm. It adds a fixed value to the ASCII (unicode) value of each c Decrypting a text is simply shifting it back by the same amount, that is, it substracts the same value from the cha arguments: the first is the character vector to be encrypted, while the second is the shift amount. The function re needs to work with all the visible ASCII characters from space to ~. The ASCII codes of these are 32 through 12 around. For example, if we shift ~ by 1, the result should be space. If we shift space by -1, the result should be ~ starting on this assignment: Sparse Matrix A sparse matrix is a large matrix with almost all elements of the same value (typically zero). The normal represe information can be captured with much less. A possible way to represent a sparse matrix is with a cell vector wh sparse matrix. The second element is a scalar specifying the default value of the sparse matrix. Each successive element of the sparse matrix that has a value other than the default. The three elements are the row index, the c sparse2matrix that takes a single input of a cell vector as defined above and returns the output argument called run: Excel File I/O The attached D ( Text File I/O Write a function called char_counter that counts the number of a certain character in a text file. The function tak character, the char it counts in the file. The function returns charnum, the number of characters found. If the file -1. As an example, consider the following run. The file "" contains a single line: "This file should have e charnum = char_counter('','a') charnum = 3 You may find it helpful to download the files for testing and dubugging in MATLAB. Saddle Points Write a function called saddle that finds saddle points in the input matrix M. For the purposes of this problem, a or equal to every element in its row, and less than or equal to every element in its column. Note that there may b that has exactly two columns. Each row of indices corresponds to one saddle point with the first element of the r element containing the column index. If there is no saddle point in M, then indices is the empty array. mage blur Write a function called blur that blurs the input image. The function is to be called like this: output = blur(img,w); where img, the input image is a two-dimensional matrix of grayscale pixel values between 0 and 255. Blurring is every pixel. Specifically, the output pixel value is the mean of the pixels in a square submatrix of size 2w+1 wher use a 3x3 matrix, that is, we average all the neighboring pixels of the given pixel and itself. Only use valid pixels example, the blurred value corresponding to w = 1 at index (1,1) would be the mean of of elements (1,1), (1, 2), uint8. Echo Generator Write a function called echo_gen that adds an echo effect to an audio recording. An echo is the original signal d the echo and then add it to the original signal with the correct offset. The function is to be called like this: output = echo_gen(input, fs, delay, amp); where input is a column vector with values between -1 and 1 representing a time series of digitized sound data. specifies how many samples we have in the data each second. For example, an audio CD uses 44,100 samples echo in seconds. That is, the echo should start after delay seconds have passed from the start of the audio sign typically this is a value less than 1 because the echo is not as loud, your function should work if amp is greater t The output of the function is a column vector containing the original sound with the echo superimposed. The out zero (round to the nearest number of points needed to get the delay, as opposed to floor or ceil). A sound record values to be outside of this range, you will need to scale the entire vector, so that all values are within the range MATLAB has several sample audio files included that you can try: splat, gong, and handel are a few examples load gong % loads two variables, y and Fs sound(y, Fs) % Outputs sound To hear the sound you will need to use desktop MATLAB or MATLAB Online. (Note that we are assuming mono audiofiles. You can load your own audio files using the audioread function (htt MATLAB. If the audio data has two columns, it is a stereo file, so use only one column of the data when testing y

Meer zien Lees minder
Instelling
Vak











Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
13 december 2020
Aantal pagina's
54
Geschreven in
2020/2021
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

12/13/2020 MathWorks Learning Tool




MATLAB as a Calculator
We borrowed $1000 at a 10% annual interest rate. If we did not make a payment for two years, and assuming th
Assign the result to a variable called debt.




Script 

 Save  Reset  MATLAB Documentation (https://www.mathworks.com/help/)


1 money_borrowed=1000;
2
3 interest_rate=.10;
4
5 end_loan_of_first_year=(money_borrowed*interest_rate)+money_borrowed
6
7 new_interest=end_loan_of_first_year*interest_rate
8
9
10 debt=end_loan_of_first_year+new_interest


 Run Script 




Previous Assessment: All Tests Passed Submit 


 correct debt value?




Output

end_loan_of_first_year =

1100



new_interest =

110


https://learningtool.mathworks.com/launch 1/2

,12/13/2020 MathWorks Learning Tool



debt =

1210




https://learningtool.mathworks.com/launch 2/2

, 12/13/2020 Lesson 2 Wrap-up | Coursera



Lesson 2 Wrap-up
TOTAL POINTS 10



1. The value of a after this command: a = [0; 0; 1]' * [1 2 3; 4 5 6; 7 8 9] 1 point


[3 , 6 , 9]

[7, 8 , 9]

[3 ; 6 ; 9]

[7 ; 8; 9]




2. What will be the value of s after this command: A = [1:4; -2:2:5; 3 1 0 -1]; s = A(end- 1 point
1,end-1);

2

-1

0

We get an error message.




3. Which of the following is a valid variable name? 1 point


All of the options above are invalid.

5x2x3x

MATLAB_Rulez!

I_Hate_This_Quiz_So_Much




4. After this command: v = 111:-11:1; how many elements will v have? 1 point


11



https://www.coursera.org/learn/matlab/exam/24JUA/lesson-2-wrap-up/attempt 1/3

Beoordelingen van geverifieerde kopers

Alle reviews worden weergegeven
4 jaar geleden

5.0

1 beoordelingen

5
1
4
0
3
0
2
0
1
0
Betrouwbare reviews op Stuvia

Alle beoordelingen zijn geschreven door echte Stuvia-gebruikers na geverifieerde aankopen.

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
CourseHeroes Science College
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
117
Lid sinds
5 jaar
Aantal volgers
113
Documenten
29
Laatst verkocht
3 maanden geleden
AskSamar

Get All Course/Questions Answer/Documents/Flashcards/Bundles Without Any Hassle.

3.9

21 beoordelingen

5
14
4
1
3
0
2
2
1
4

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen