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

  Implement a class student

Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply a suitable constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).

  Explain we have to make a project in java

We have to make a project in java . This is a small deskstop application no specifications given so far . The CD store has CD games and music we can rent a cd or we can buy . This is all we need to develop.

  Prompt the user for a series of numbers

Prompt the user for a series of numbers that may be either a binary number or a decimal number.

  Create a messageframe class extending jframe

Create a MessageFrame class extending JFrame and a MessagePanel class extending JPanel.

  Create java program to describe inheritance and polymorphism

Create a Java program based on the geometric shapes example described at the beginning of this lesson using Classes Square, Triangle, Rectangle, and Circ leto help describe inheritance and polymorphism.

  Java program using the net beans ide

For this Assignment, you will update an existing Java program using the NetBeans IDE. You will use the NetBeans Integrated Development Environment to make changes to an existing NetBeans Java Project.

  Using the java development kit and jgrasp

Using the Java Development Kit and jGrasp, develop a program in response to the following prompt:

  What is the paintcomponent method how is it used in java

q1. what is the paintcomponent method? how is it used in java graphics? how does a program intentionally cause the

  Program that counts the number of occurrences of lowercase

Write a program that counts the number of occurrences of lowercase and uppercase vowels in entered lines of text. Use a two-dimensional array to store the vowel counts. The array's first column holds the counts for the lowercase vowels, and the secon..

  Bulloil company is planning a large pipeline from east to

bulloil company is planning a large pipeline from east to west x-axis across its oil fieldbullthe field has n

  That uses a library database of books

Write a Java program that uses a library database of books and patron data, as described in Exercise R22.2. Patrons should be able to check out and return books

  Using your musicalinstrument class

Finally, create a Java test class that simulates using your MusicalInstrument class.  In your test class you should at a minimum: a) Construct 4 instances of your instrument, b) tune your instruments, c) print the name of your instrument d) print ..

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