Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M91411382
  • Price:- $90

Priced at Now at $90, Verified Solution

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As