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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic 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