Ask Question, Ask an Expert


Ask MATLAB Expert


problem 1: Practice Vector Manipulation

prepare single MATLAB statements to create these vectors from any vector Z. You can use vector Z shown as a sample input. Create a single m-file script (non-function) to containing all the statements. Comment each problem 'a' through 'e' in your m-file.

Z = [4 5 2 8 4 7 2 64 2 57 2 45 7 43 2 5 7 3 3 6523 3 4 3 0 -65 -343];

a) Create a new vector vecA that is the odd numbered elements of Z (not the odd values, the elements with odd indexes).

b) Count how many elements of Z are less than or equal to 10.

c) Create a new vector vecC that is the same as Z except all the odd values of Z are changed to even by adding 1 to them.

d) prepare a single MATLAB statement to generate 100 random integers with values -1 or 0 or 1.

e) Create a new vector vecE that contains all the elements of Z that are a multiple of 3

f) Create a new vector vecF that is the same as Z except the first and last elements are swapped and nothing else is changed.

g) find out how many elements of Z are within 10 of the max element in Z (include the max element(s) in your count).

h) Create a new vector vecH that has the sum of the first and second elements of Z in the first position of vecH, the sum second and third elements of Z in the second position of vecH, the sum third and fourth elements of Z in the third position of vecH, etc. The last element of vecHis just the last elementof Z.

problem 2: Create m-file functions to solve some basic vector problems in MATLAB.

For each problem complete the following steps:

A) Draw a picture or prepare pseudocode for solving the problem using composition (you do not have to hand this in)

B) By hand, make an estimate of roughly the scale of the answer (you do not have to hand this in).

C) prepare an m-file function to solve the problem.

D) Test your m-file function using MATLAB in "calculator" mode with the diary on to save all your work in a command history file. It is fine to include errors in your command history file, as long as you eventually compute correctly. If you discover mistakes in your program, correct them and execute again. Please format the results to significant digits that are correct for the problem and data given.

How to create a command history file??

>> diary BauerLab6.txt
. . .
>> diary off


A) You are asked to determine the most efficient solid shape (defined by the shape with largest ratio of volume to its surface area) for a large hot air balloon. prepare a matlab script m-file named Efficient.m (function not necessary) to create a vector containing the ratios of the volume of a sphere to the surface area for a sphere for radius "r" values ranging from 50 to 100 by 2s.

Do the same thing for the volume and surface area of a cube with side length "r" values ranging from 50 to 100 by 2s

Do the same thing for the volume and surface area of a tetrahedron (equilateral triangle based pyramid) with side length "r" values ranging from 50 to 100 by 2s.

Finally, plot the three vectors of ratios on the same graph, x-axis is the "r" vector, y-axis is the ratio of volume to surface area vector. Use different colors or symbols for each plot, label the axes, and add a legend. Which solid shape shape is most efficient (most volume per surface area)?

B) A vector 'v' stores for the letter grades ('A', 'B', 'C', 'D', 'E') for a student's classes for a term. A student can have from 1 to 6 classes. Assume every class is a 3 credit hour class and assume each grade is worth this many grade points. A = 4, B = 3, C = 2, D = 1, E = 0 prepare a function call myGPA that has a single vector argument of grades as described above, and find outs and returns the GPA for the term. NO IF STATEMENTS ARE NEEDED, use vector conditions/manipulations) Sample call and result:

>> GPA = myGPA(['B' 'A' 'A' 'C' 'B'])

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M91246

Have any Question? 

Related Questions in MATLAB

Problem -tom cat is chasing jerry mouse the initial

Problem - Tom cat is chasing Jerry mouse the initial distance between them is S 0 = 100m. Tom runs V c = 4-at m/s (negative accident) Jerry's velocity depends on the distance between Tom& Jerry V = Vmax - Ks (3-0.025 m/s ...

1 calculate the following for the function f x e-3x -

1) Calculate the following for the function f (x) = e -3x - 2x a. Calculate the derivative of the function by hand. Write a MATLAB function that calculates the derivative of this function and calculate the derivative at ...

Question 1backgroundyou have been asked to manage a project

QUESTION 1 Background You have been asked to manage a project to install a pipeline from an offshore gas platform to an onshore gas processing plant, and to find the cheapest design that is possible. The platform is Q km ...

Instructions for each of the following exercise create an

Instructions: For each of the following exercise, create an M-file to store the MATLAB commands. Copy and paste the M-file into a text document. Include in the text document the pictures produced by MATLAB. Resize and cr ...

Question 1 a what is the period of the forced oscillation

Question 1. (a) What is the period of the forced oscillation? What is the numerical value (modulo 2Π) of the angle α defined by? (b) In this question you are asked to modify the file LAB06ex1.m in order to plot the compl ...

Matlabproject descriptionwrite a mileage per gallons and

MATLAB Project description: Write a mileage per Gallons and miles per dollar calculator program using two functions, one to calculate MPG and one to calculate MPD. The application will prompt the user to type the odm rea ...

Reports of projectproblem design a fourbar grashof

REPORTS OF PROJECT PROBLEM: Design a fourbar Grashof crank-rocker to give? (Everyone will determine the terms given by professor) of rocker rotation with equal time forward and back, from a constant speed motor input. 1- ...

Use matlab to solve the following equations please i plot

Use Matlab to solve the following equations. Please (i) plot the solution as a function of t for t  ∈ [0, 100]. (ii) draw the phase diagram of the ODE. 1. dy/dt = y 2 + y with y(0) = 1         dy 1 /dt = y 2 2.           ...

Question 1backgroundclimate change is a change in global or

QUESTION 1 Background Climate change is a change in global or regional climate patterns, in particular a change apparent from the mid to late 20th century onwards and attributed largely to the increased levels of atmosph ...

Problem 1 10pts the csu-chill radar made observations of

Problem 1 [10pts.]: The CSU-CHILL radar made observations of the Ponnequin Wind Farm located on the boarder of Wyoming and Colorado near I-25. The wind farm is approximately 62 km away from the radar. Complex valued digi ...

  • 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

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen