Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
351 views

Matlab Assignment 1

1. The document contains 10 MATLAB assignment problems ranging from writing simple programs that greet users and calculate quadratic roots, to more complex programs involving arrays, vectors, and financial calculations. 2. The problems involve writing MATLAB programs to calculate sums, trigonometric identities, statistical measures, squares of numbers, passwords, vector products, and furniture store sales and profits. 3. The programs are to prompt for user input where needed, perform the specified calculations, and output results to the user.

Uploaded by

Gayathri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
351 views

Matlab Assignment 1

1. The document contains 10 MATLAB assignment problems ranging from writing simple programs that greet users and calculate quadratic roots, to more complex programs involving arrays, vectors, and financial calculations. 2. The problems involve writing MATLAB programs to calculate sums, trigonometric identities, statistical measures, squares of numbers, passwords, vector products, and furniture store sales and profits. 3. The programs are to prompt for user input where needed, perform the specified calculations, and output results to the user.

Uploaded by

Gayathri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MATLAB ASSIGNMENT-2

1. Greeting. Write a MATLAB program, greeting.m that asks +for the first name of the
user and then greets the user. Something like this: What is your first name? Alfonso
Good morning, Alfonso! Glad to be computing with you today.

2. Quadratic roots2. Write a program, quadroots2.m, to prompt the user to enter in turn
a, b, and c, and then calculate the roots of the quadratic equation. Something like this:
***********************************
Quadra c Solver for axˆ2+bx+c=0
Please enter a: xx
Please enter b: xx
Please enter c: xx
The roots are: Z1=xxxxx Z2=xxxxx
3. Sum next 10. Write a program, sum10.m, which asks the user for
an integer and then finds the sum of that number and the next
nine integers following that number. Report the result to the user,
which should look something like: The sum of the integers from 4
through 13 is 85.
4. Trig identity. Write a program, trigid.m that takes an array of five
angles and computes two new arrays, the sines of the elements in
the first array, and the cosines. Then use array operations to show
that cos2 (x) + sin2 (x) = 1 for each angle in the original array.
5. Test statistics. Write a program, teststats.m that prompts the user to enter
5 test scores. Then compute the mean, median, mode, and variance for the
scores entered using the appropriate MATLAB functions. (Use help or doc if
you need information on these functions.) Report the results for these test
scores to the user.
6. Squares of numbers. Write a program, squares.m that uses
linspace to create and array of integers from 10 to 20 inclusive and
then computes and reports the square of each integer.
7. Squares with user input. Modify the squares.m program to allow a
user to enter a range of integer values (e.g., from 15 to 30) and
then compute and report the square of each integer. Call the
program squares2.m.
8. Password. Write a program, password.m that asks for a user’s first name,
middle initial, last name, and 10-digit cell phone number. Create a six-
character password for the user, using the first letter of the first name, the
middle initial, the first two letters of the last name and the last two digits of
the telephone number. Report the password to the user. All letters in the
password should be lowercase.
9. Vector products. Write a program, dotcross.m, that finds the dot product
and cross product of two three-dimensional row vectors. Recall that the dot
product of two three dimensional vectors is defined to be v · w = v1w1 +
v2w2 + v3w3 and the cross product of two vectors is defined to be the
vector v × w = (v2w3 − v3w2, v3w1 − v1w3, v1w2 − v2w1). Display the
results in the Command window.
10.Furniture sales. A discount furniture store sells four types of bedroom sets. The cost
(in dollars) of each set can be represented by the array Cs = [199, 268, 500, 670]. The
price at which the store sells each set can be represented by the array Ps = [398, 598,
798, 998]. In a particular quarter the number of sets sold of each type can be
represented by the array Ns = [35, 25, 20, 10]. Write a program, furniture.m, that
calculates and reports: a. The total number of bedroom sets sold. b. The total revenue
received by the store from the number of sets sold. c. The profit realized by the store
from the sale of bedroom sets.

You might also like