Laboratory #2 Solution

$30.00

Category:

Description

PURPOSE:  Further practice with MATLAB.

 

For each problem, create a MATLAB script file and name it FIRSTNAME_LASTNAME_LAB2_ problemX.m. Put ALL the commands for the required steps in your script file:

  • Be sure to clear the display and the memory.
  • Display your name.
  • Separate and label different steps using comments.

———————————————————————————————————————

%{

Class: ENGR15100: Software Tools for Engineers

Instructor: Xiaoli Yang

Author: [Student’s Name]

Assignment: Lab [No.]

File Name: LASTNAME_LAB[No.]_problem[No.].m

Date: [MM]/[DD]/[YY]

%}

 

%Delete an eventual pre-existing diary

delete xxx.txt

 

%Turn on a diary called mydiary.txt

diary xxx.txt

 

%clear screen

clc

 

%clear workspace

clear

 

disp(‘Your Name Here’);

disp(”);

disp(‘starting code: ‘);

 

%Completing lab x

%your source code here%

 

%Turn off the diary function

diary off

———————————————————————————————————————

Problem 1(10 points)

Display both the string “Hello World.” and the numeric value stored in variable x (x’s value is 173.0192) by using the built-in function named disp. An expected/sample output after executing this step is shown below:

Hello World.

——————————————
The value of scalar variable x is:
——————————————
173.0192

 

 

Problem 2(20 points)

   a=

 

   b=

 

 

   c=

 

 

  

   e=

 

 

 

  • Find
  • Find
  • Find
  • Find
  • Find
  • Find

 

PROBLEM 3(10 points)

Using what you have learned thus far:

  • Activate a diary of FIRSTNAME_LASTNAME_LAB2_problem3.txt in the script
  • Set up the vector from 0.4 (start value) to 5.0 (final value) by 0.01 (step increment)
  • Calculate
  • Turn off the diary

 

 

problem 4(20 points)

  • Activate a diary of FIRSTNAME_LASTNAME_LAB2_problem4.txt in the script
  • A food company manufactures five types of Trail mix packages using different mixtures of peanuts, almonds, walnuts, raisins, and M&Ms. The mixtures have the following compositions:
  Mix 1 Mix 2 Mix 3 Mix 4 Mix 5
Peanuts (oz) 3 1 1 2 1
Almonds (oz) 1 2 1 3 1
Walnuts (oz) 1 1 0 3 3
Raisins (oz) 2 0 3 1 2
M&Ms (oz) 1 2 3 0 2

 

  • How many packages of each mix can be manufactured if of peanuts,  of almonds,  of walnuts,  of raisins, and  of M&Ms are available? Write a system of linear equations and solve in MATLAB.
  • Turn off the diary.

problem 5(20 points)

  • Activate a diary of FIRSTNAME_LASTNAME_LAB2_problem5.txt in the script
  • Enter and solve the following system of linear algebraic equations:

5x – 4y +6z    = 37

11x +3y +3z   = -5

5x + 6y +z = -3

  • Solve it by hand first and then solve it using MATLAB. Display using the command FPRINTF the values for x, y, and z. Make sure the values are clearly labeled.
  • Turn off the diary.

problem 6(20 points)

  • Activate a diary of FIRSTNAME_LASTNAME_LAB2_problem6.txt in the script
  • Using the INPUT command three times, ask the user to insert the values of A, D (enter values for both 0.75 < (A,D) < 3), and phi (f, an angle measured in radians, between 0 and 2p).
  • Set up the vector t from 0 (start value) to 3.0 (final value) by 0.03 (step increment)
  • Calculate v = . Note the equation on the left is not in MATLAB format. Display the value of v using the command FPRINTF.
  • Turn off the diary

 

SUBMITTING YOUR LAB:

Submit your lab by uploading .m files using the Blackboard Assignment feature no later than the date specified.


error: Content is protected !!