Briefly describes all of the special characters commands

Assignment Help MATLAB Programming
Reference no: EM131175671

142 Chapter 4 Manipulating MATLAB® Matrices

MATLAB® SUMMARY

The following MATLAB® summary lists and briefly describes all of the special char-acters, commands, and functions that were defined in this chapter.

Special Characters

: colon operator

... ellipsis, indicating continuation on the next line

[] empty matrix

Commands and Functions

meshgrid maps vectors into a two-dimensional array

zeros creates a matrix of zeros

ones creates a matrix of ones

diag extracts the diagonal from a matrix

fliplr flips a matrix into its mirror image, from left to right

flipud flips a matrix vertically

magic creates a "magic" matrix

KEY TERMS

elements magic matrices subscripts

index numbers mapping 

PROBLEMS

Manipulating Matrices

4.1 Create the following matrices, and use them in the exercises that follow:

(a) Create a matrix called d from the third column of matrix a.

(b) Combine matrix b and matrix d to create matrix e, a two-dimensional matrix with three rows and two columns.

(c) Combine matrix b and matrix d to create matrix f, a one-dimensional matrix with six rows and one column.

(d) Create a matrix g from matrix a and the first three elements of matrix c, with four rows and three columns.

(e) Create a matrix h with the first element equal to a1,3, the second ele-ment equal to c1,2, and the third element equal to b2,1.

PDF processed with CutePDF evaluation edition www.CutePDF.com

Problems 143

4.2 Load the file thermo_scores.dat provided by your instructor, or enter the matrix at the top of page 137 and name it thermo_scores. (Enter only the numbers.)

(a) Extract the scores and student number for student 5 into a row vector named student_5.

(b) Extract the scores for Test 1 into a column vector named test_1.

(c) Find the standard deviation and variance for each test.

(d) Assuming that each test was worth 100 points, find each student's final total score and final percentage. (Be careful not to add in the student number.)

(e) Create a table that includes the final percentages and the scores from the original table.

(f) Sort the matrix on the basis of the final percentage, from high to low (in descending order), keeping the data in each row together. (You may need to consult the help function to determine the proper syntax.)

4.3 Consider the following table:

Time Thermocouple 1 Thermocouple 2 Thermocouple 3

(a) Create a column vector named times going from 0 to 24 in 2-hour increments.

(b) Your instructor may provide you with the thermocouple temperatures in a file called thermocouple.dat, or you may need to create a matrix named thermocouple yourself by typing in the data.

(c) Combine the times vector you created in part (a) with the data from thermocouple to create a matrix corresponding to the table in this problem.

(d) Recall that both the max and min functions can return not only the maximum values in a column, but also the element number where those values occur. Use this capability to determine the values of times at which the maxima and minima occur in each column.

4.4 Suppose that a file named sensor.dat contains information collected from a set of sensors. Your instructor may provide you with this file, or you may need to enter it by hand from the following data:

Each row contains a set of sensor readings, with the first row containing values collected at 0 seconds, the second row containing values collected at 1.0 seconds, and so on.

(a) Read the data file and print the number of sensors and the number of seconds of data contained in the file. (Hint: Use the size function- don't just count the two numbers.)

(b) Find both the maximum value and the minimum value recorded on each sensor. Use MATLAB® to determine at what times they occurred.

(c) Find the mean and standard deviation for each sensor and for all the data values collected. Remember, column 1 does not contain sensor data; it contains time data.

4.5 The American National Oceanic and Atmospheric Administration (NOAA) measures the intensity of a hurricane season with the accumulated cyclone energy (ACE) index. The ACE for a season is the sum of the ACE for each tropical storm with winds exceeding 35 knots (65 km/h). The maximum sustained winds (measured in knots) in the storm are measured or approxi-mated every six hours. The values are squared and summed over the dura-tion of the storm. The total is divided by 10,000, to make the parameter easier to use.

This parameter is related to the energy of the storm, since kinetic energy is proportional to velocity squared. However, it does not take into account the size of the storm, which would be necessary for a true total energy estimate. Reliable

storm data have been collected in the Atlantic Ocean since 1950, and are included here. This data may also be available to you from your instructor as an EXCEL worksheet, ace.xlsx, and was extracted from the Accumulated Cyclone Energy article in Wikipedia. (https://en.wikipedia.org/wiki/Accumulated_ cyclone_energy). It was collected by the National Oceanic and Atmospheric Administration (https://www.aoml.noaa.gov/hrd/tcfaq/E11.html).

(a) Import the data into MATLAB®, and name the array ace_data.

(b) Extract the data from each column, into individual arrays. You should have arrays named

• years

• ace

• tropical_storms

• hurricanes

• major_hurricanes

(c) Use the max function to determine which year had the highest

• ACE value

• Number of tropical storms

• Number of hurricanes

• Number of major hurricanes

(d) Determine the mean and the median values for each column in the array, except for the year.

(e) Use the sortrows function to rearrange the ace_data array based on the ACE value, sorted from high to low.

The data presented in this problem is updated regularly. Similar data is available for the eastern Pacific and central Pacific oceans.

Problems with Two Variables

4.6 The area of a triangle is, area 5 ½ base × height (see Figure P4.6). Find the area of a group of triangles whose base varies from 0 to 10 m and whose height varies from 2 to 6 m. Choose an appropriate spacing for your calcu-lational variables. Your answer should be a two-dimensional matrix.

4.7 A barometer (see Figure P4.7) is used to measure atmospheric pressure and is filled with a high-density fluid. In the past, mercury was used, but because of its toxic properties it has been replaced with a variety of other fluids. The pressure, P, measured by a barometer is the height of the fluid column, h, times the density of the liquid, r, times the acceleration due to gravity, g, or

P 5hrg

This equation could be solved for the height:

P h 5 rg

Find the height to which the liquid column will rise for pressures from 0 to 100 kPa for two different barometers. Assume that the first uses mercury, with a density of 13.56 g/cm3 (13,560 kg/m3) and the second uses water, with a density of 1.0 g/cm3 (1000 kg/m3). The acceleration due to gravity is 9.81 m/s2. Before you start calculating, be sure to check the units in this calculation. The metric measurement of pressure is a pascal (Pa), equal to l kg/m s2. A kPa is 1000 times as big as a Pa. Your answer should be a two-dimensional matrix.

4.8 The ideal gas law, Pv 5 RT, describes the behavior of many gases. When solved for v (the specific volume, m3/kg), the equation can be written

v 5 RT
P

Find the specific volume for air, for temperatures from 100 to 1000 K and for pressures from 100 kPa to 1000 kPa. The value of R for air is 0.2870 kJ/(kg K). In this formulation of the ideal gas law, R is different for every gas. There are other formulations in which R is a constant, and the molecular weight of the gas must be included in the calculation. You'll learn more about this equation in chemistry classes and thermodynamics classes. Your answer should be a two-dimensional matrix.

Special Matrices

4.9 Create a matrix of zeros the same size as each of the matrices a, b, and c from Problem 4.1. (Use the size function to help you accomplish this task.)

4.10 Create a 6 3 6 magic matrix.

(a) What is the sum of each of the rows?

(b) What is the sum of each of the columns?

(c) What is the sum of each of the diagonals?

4.11 Extract a 3 3 3 matrix from the upper left-hand corner of the magic matrix you created in Problem 4.9. Is this also a magic matrix?

 

4.12 Create a 5 3 5 magic matrix named a.

(a) Is a times a constant such as 2 also a magic matrix?

(b) If you square each element of a, is the new matrix a magic matrix?

(c) If you add a constant to each element, is the new matrix a magic matrix?

a 2*a (d) Create a 10 3 10 matrix out of the following components (see Figure P4.12):
• The matrix a

• 2 times the matrix a

a^2 a 2 • A matrix formed by squaring each element of a
• 2 plus the matrix a

Is your result a magic matrix? Does the order in which you arrange the com-
Figure P4.12
ponents affect your answer?
Create a matrix out of other
4.13 Albrecht Durer's magic square (Figure 4.8) is not exactly the same as the

matrices.
4 3 4 magic square created with the command magic(4)

(a) Recreate Durer's magic square in MATLAB® by rearranging the columns.

(b) Prove that the sum of all the rows, columns, and diagonals is the same.


Attachment:- Chapter_4_-_Homework.pdf

Reference no: EM131175671

Questions Cloud

What are 2 possible reasons for the variances : What are O'Brien Vineyards labor efficiency variance and the labor rate variance?- Is the variances favorable or unfavorable?- What are 2 possible reasons for the variances?
Explain the situation of the event : Explain the situation of the event. Describe the company's ethical obligation in their communications to the public
How you put your beliefs into practice by including examples : It should also discuss how you put your beliefs into practice by including concrete examples of what you do or anticipate doing in the classroom.
Direct materials price and quantity variances : Summarize the variances that you computed in above by showing the net overall favorable or unfavorable variance for October.
Briefly describes all of the special characters commands : The following MATLAB® summary lists and briefly describes all of the special char-acters, commands, and functions that were defined in this chapter.
Are digital technology good influence to society and culture : Referencing three examples (one from the beginning, one from the middle, and one from the end) of "Digital Nation," explain what we have learned this term about the influence of digital technologies on society and culture over the course of this t..
Diagram and explain the life cycle of a supply chain : Diagram and explain the life cycle of a supply chain. Explain, and provide examples of, the models organizations use to manage forecasting, planning, and inventory
Understanding of services marketing concepts and theories : demonstrate your understanding and comprehension of services marketing concepts and theories via the appropriate application of relevant theories and concepts in your analysis of that service experience, which could center around (but not limited..
How old is a rock that contains the isotope : If an isotope has a half-life of 600 million years, how old is a rock that contains the isotope after 50% of the parent has decayed? How old is the rock after four half-lives have passed?

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Write matlab scripts

Write MATLAB scripts for to accept two numbers from the user; Display all prime numbers between these two numbers.

  Solve a linear system of equations

Solves a linear system of equations using naïve Gaussian elimination - You can use the ‘backslash' Matlab operator for solving the systems of equations.

  Implement the support vector machine algorithm

Write a program to implement the Support Vector Machine algorithm. Train an SVM classifer with data from to3 and (04 in the following way - Train your classifier with just the first patterns in 03 and aht and find the separating hyperplane and the ..

  Write a function that takes a list of integers

Using ML write a function that takes a list of integers as argument and returns a pair consisting of the sum of the even position and the sum of the odd positions of the list.

  Determine and explain cost function and decision variables

Determine and explain the cost function and decision variables and define a problem of your choice which can be tackled by Biologically Inspired Methods.

  Give the gradient operator in paraboloidal coordinates

Given that the le data.txt contains only real numbers seperated by white space, write down a sequence of maple commands that will read the data into a maple list and then plot a histogram of the elements in the list.

  Write a matlab that given a sequence of samples

Write a MATLAB or Octave program that, given a sequence, f[k], of samples in the time domain, calculates a filtered output y[k], given by the formula y[k]=-a_2[k-1]-a_1y[k-2]-a_0y[k-3]+b_3f[k]+b_2f[k-1]+b_1f[k-2]+b_0f[k-3].

  An image histogram for a color image

goal is to build an image histogram for a color image based on its 6-bit color code.

  Time domain design and analysis

To design a "custom" controller to reduce the vibrations of the seat and a PID controller to reduce the vibration of the seat

  Build a simple revolvate robot

Define the robot as Robot.  Use the appropriate functions (i.e. methods) in the Robotics Toolbox - Generate a second pose and re-plot it.

  Dimensional plot of the free surface charge

Include a qualitative dispersion curve sketch thatdemonstrates the operating point at which your Matlab plot applies.

  Write a simple program that stores the high temperatures

A meteorological company wants you to write a simple program that stores the high temperatures and low temperates for each of the months of the year. After consulting with trusted programming partners, you come up with a great idea

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