Expressions in the matlab command window

Assignment Help JAVA Programming
Reference no: EM13841569

Part 1:

These problems all involve typing expressions in the MATLAB command window. To complete this homework assignment, turn in a text (or Word, or PDF) file containing the expression that you type to respond to each problem.

1. Find an efficient way to generate the following matrix:

mat =

7 8 9

12 10 8 10 6

Give expressions that, for the matrix mat,

a. Refer to the scalar value 6 using subscript notation.

b. Refer to the entire second row.

c. Refer to the first two columns

2. Create a vector x that consists of 20 equally spaced values from -π to π. Create a 20-element y vector in which every element is the sine of the corresponding element in x.

3. Create a 4 x 2 matrix of all zeros and store it in a variable. Then, replace the second row in the matrix with a vector consisting of a 3 and a 6.

4. Using the colon operator, create the following row vectors:

a. 3 4 5 6

b. 1.0000 1.5000 2.0000 2.5000 3.0000

c. 5 4 3 2

5. Use the help function to learn about the function rand. Create a 3 x 5 matrix of random real numbers. Delete the third row.

6. Create two 3 x 3 matrices of random real numbers. Create a third matrix in which each element is the product of the corresponding elements in these two matrices. Create a fourth matrix that is the product of matrix multiplication of the first two matrices.

7. Create four 4-element vectors of random real numbers in the range of 1 to 100. Concatenate these vectors together to form a 4 x 4 matrix. Multiply this matrix by itself.

Part 2:

To complete this homework assignment, turn in a text (or Word, or PDF) file containing the MATLAB code that you generate in response to each problem.

1. Write a script that asks for a vector as user input and then prints out the elements of the vector in sentence format. For instance if the vector is [5.5 11.3 4.35], the script will display the following:

Element 1 is 5.5.
Element 2 is 11.3.
Element 3 is 3.45.

The script should work regardless of how many elements are in the vector.

2. The inverse of the mathematical constant e can be approximated as:

1/e ≈ (1 - 1/n)n

as n approaches infinity. Write a script that will loop through increasing values of n until the difference between this approximation and the actual value is less than 0.0001. The script should then display the actual value of e-1 and the approximation to four decimal places, and also display the value of n required to achieve such accuracy.

3. In thermodynamics, the Carnot efficiency is the maximum possible efficiency of a heat engine operating between two reservoirs at different temperatures. The Carnot efficiency is given as:

n = 1 - TC/TH

where TC and TH are the absolute temperatures of the cold and hot reservoirs, respectively. Write a script that will prompt the user for the two reservoir temperatures in Kelvin and print the corresponding Carnot efficiency to three decimal places. The script should errorcheck the user's input since absolute temperature cannot be less than or equal to zero. The script should also swap the temperature values if TH is less than TC.

Part 3:

To complete this homework assignment, turn in a m-file containing the MATLAB code that you generate in response to each problem.

1. Write a script that plots exp(x) for values of x ranging from -2 to 2 in steps of 0.1. The plot should have an appropriate title and labeled axes.

2. If a certain amount of money (called the principal P) is invested in a bank account, earning an interest rate i compounded annually, the total amount of money Tn that will be in the account after n years is given by:

Tn = P(1 + i)n

Write a function that will receive input arguments for P, i, and n, and will return the total amount of money Tn. Write a script that calls this function to plot Tn after 20 years as a function of interest rate, with interest rate ranging from 0 to 10% in increments of 0.1%.

3. Write a script that creates a file called testtan.mat comprised of two lines with three real numbers on each line (some negative, some positive, in the range of -1 to 3). Write a second script that loads the file into a matrix and computes the tangent of every element in the matrix

4. Write a script that will continue prompting the user for positive numbers, and storing them in a vector variable, until the user types in a negative number. Upon the user typing in a negative number, the stored vector should be saved to a file and the program should terminate.

Reference no: EM13841569

Questions Cloud

Discuss the budgetary and managerial impact : Discuss the budgetary and managerial impact
What is the main technique that swift employs : What is the main technique that Swift employs to make his point. Is Swift's choice of approach effective or ineffective. Why
Explain how nafta affected the reaction of naics : Review the North American Free Trade Agreement (NAFTA) at the Executive Office of the President website and the North American Industry Classification System (NAICS) at the U.S. Census Bureau Website. Explain how NAFTA affected the reaction of NAI..
Public-private partnership and democracy : Public-Private Partnership and Democracy
Expressions in the matlab command window : These problems all involve typing expressions in the MATLAB command window. To complete this homework assignment, turn in a text (or Word, or PDF) file containing the expression that you type to respond to each problem.
To access and download stock : The objectives of this exercise: 1. To access and download stock and index price data from yahoo.com. 2. To discern the difference between a real-time closing price and an adjusted price.
What have been the effects of the bill of rights? : What have been the effects of the Bill of Rights?
Identify strategies for combatting insider threats : Identify strategies for combatting Insider Threats. Out of the ‘'Top threats'' which threat you regard to be the most significant and why?
Evaluate laws and regulations relative to product safety : evaluate laws and regulations relative to product safety and liability

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a new project in bluej by clicking on the menu option

Create a new project in BlueJ by clicking on the menu option Project > New project. This will create a folder with the project name (see below). All BlueJ project-related files for this project will be stored in this folder. Create new classes by ..

  Implement a class person with two fields name

Implement a class Person with two fields name and age, and a class Car with three fields - implement a class that saves the details of the person.

  Benefits of using java as a programming language

What are the benefits of using Java as a programming language? Discuss how the use of an integrated development environment (IDE) such as Eclipse enhances programmer productivity

  How to write and incorporate string

How to write and incorporate string - custom function

  Write an applet that includes a pie chart

Write an applet that includes a pie chart. Use a news article with statistics that are good candidates for a pie chart: for example, political candidate preferences; percentages of those for, against, or undecided about a ballot measure; and so for..

  Redesign the grading program as an object-oriented design

redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles)

  Write a java class

Write a Java class called PQueue that extends the provided abstract QueueADT class.

  Design and implement a java program to determine the sum

Design and implement a Java program that will gather a group of floating point numbers and determine the sum and average of the data entered. The program should use separate methods for inputting the data, calculating the sum, calculating the aver..

  E-marketing-e-commerce consultant

You are an e-marketing and e-commerce consultant. Mary and Joe Johnson, the owners of Book Bunker, have hired you to help them improve their sales both online and in their store.

  Define a class called counter

Define a class called Counter. An object of this class is used to count things, so it records a count that is a non negative whole number. Include methods to set the counter to 0, to increase the count by

  Design a program in pseudocode

Design a program in pseudocode that solves this problem. You are required to generate only the pseudocode - No charting or analysis section is required, but you may have to incorporate the bubble sort algorithm to determine the minimum and maximum..

  Program should assign a seat in the first class

If a person enters 1, your program should assign a seat in the first class (rows 1 - 3). If a person enters 2, your program should assign a seat in business class (rows 4 - 7). If a person enters 3, your program should assign a seat in economy class ..

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