Create a row vector for theta with the values zero and pi

Assignment Help MATLAB Programming
Reference no: EM131122231

Exercises

Instructions:

You will need to record the results of your MATLAB session to generate your lab report. Create a directory (folder) on your computer to save your MATLAB work in. Then use the Current Directory ?eld in the desktop toolbar to change the directory to this folder. Now type

diary lab1_yourname.txt

followed by the Enter key. Now each computation you make in MATLAB will be save in your directory in a text ?le named lab1 yourname.txt. When you have finished your MATLAB session you can turn off the recording by typing diary off at the MATLAB prompt. You can then edit this ?le using your favorite text editor (e.g. MS Word).

Lab Write-up: Now that your diary file is open, enter the command format compact (so that when you print out your diary file it will not have unnecessary blank lines), and the comment line

% MAT 275 MATLAB Assignment # 1

Include labels to mark the beginning of your work on each part of each question, so that your edited lab write-up has the format.

Important: An unedited diary file without comments submitted as a lab write-up is not acceptable.

1. All points with coordinates x = r cos (θ) and y = r sin (θ), where r is a constant, lie on a circle with radius r, i.e.  satisfy the equation x2 + y2  = r2.  Create a row vector for θ with the values 0, π/4 , π/2 , 3π/4, π, and 5π/4.

Take r = 2 and compute the row vectors x and y. Now check that x and y indeed satisfy the equation of a circle, by computing the radius r = √(x2 + y2).

2. Use the linspace command or the colon operator : to create a vector t with 91 elements: 1, 1.1, 1.2, . . . , 10 and define the function y = et/10 sin (t) / (t2 + 1) (make sure you use ";"  to    suppress the output for both t and y).

(a) Plot the function y in black and include a title with the expression for y.

(b) Make the same plot as in part (a), but rather than displaying the graph as a curve, show the unconnected data points. To display the data points with small circles, use plot (t,y,'o'). Now combine the two plots with the command plot (t,y,'o-') to show the line through the data points as well as the distinct data points.

3. Use the command plot3(x,y,z) to plot the circular helix x(t) = sin t, y(t) = cos t, z(t) = t 0 ≤ t ≤ 20.

NOTE: Use semicolon to suppress the output when you define the vectors t, x, y and z. Make sure you use enough points for your graph so that the resulting curve is nice and smooth.

 4. Plot y = cos x in red with a solid line and z = 1 - x2/2 + x4/24 in blue with a dashed line for 0 ≤ x ≤ π on the same plot.

Add a grid to the plot using the command grid on.

NOTE: Use semicolon to suppress the output when you de?ne the vectors x, y and z. Make sure you use enough points for your graph so that the resulting curves are nice and smooth.

5. The general solution to the differential equation dy / dx = x + 2 is

y(x) = (x2/2) + 2x + C          with y(0) = C.

The goal of this exercise is to write a function file to plot the solutions to the differential equation in the interval 0 ≤ x ≤ 4, with initial conditions y(0) =  -1, 0, 1.

The function file should have the structure function+function (similarly to the M-file myplot1.m

Example 3, page 5). The function that defines y(x) must be included in the same file (note that the function defining y(x) will have two input arguments: x and C).

Your M-file should have the following structure (fill in all the?? with the appropriate commands):

Function ex5

x = ?? ;       % define  the  vector  x  in  the interval [0,4]
y1 = f(??);   % compute  the solution with C  =  -1
y2 = f(??);   % compute the solution with C    = 0
y3 = f(??);   % compute the solution with C  =    1
plot(??)       % plot the three solutions with different line-styles
title(??)       % add a title
legend(??)   % add a legend
end

function  y = f (x, C)
y = ??         % fill-in with  the  expression  for  the   general  solution
end

Plot the graphs in the same window and use different line-styles for each graph. To plot the graphs in the same window you can use the command hold on or use the plot command similarly to Exercise 4.

Add the title 'Solutions to dy/dx = x + 2'.

Add a legend on the top left corner of the plot with the list of C values used for each   graph.

(Type help plot for a list of the different line-styles, and help legend for help on how to add a legend.) Include both the M-file and the plot in your report.

NOTE: the only output of the function file should be the graph of the three curves. Make sure you use enough points so that the curves are nice and smooth.

6. (a) Enter the function f (x, y) = x3 + (yex / x+1) as an inline or anonymous function. Evaluate the function at x = 2 and y   = -1.

(b) Type clear f to clear the value of the function from part (a). Now write a function M-file for the function f (x, y) = x3 + (yex / x+1).  Save the file as f.m (include the M-file in your report). Evaluate the function at x = 2 and y = -1 by entering f(2,-1) in the command window.

Attachment:- MATLAB.pdf

Reference no: EM131122231

Questions Cloud

Compare outcome under the rule of negligence : For the context of product related accidents, compare the outcome under the rule of negligence with the outcome under the rule of strict liability. Assume that care is unilateral, and consumers can observe the care level adopted by the ?rm. Moreover,..
Explain in detail administrative criminology : Discuss the point of view that harsh punishment such as the death penalty fails to deter terrorists from committing acts of terrorism. Give examples in your answer
How is it used in a computerized accounting system : What is an electronic form, and how is it used in a computerized accounting system?
Cluster sampling with simple random : Assume that the following are data from cluster sampling with simple random sampling of clusters. There are 10 clusters (primary units) and a total of 100 secondary units in the population.
Create a row vector for theta with the values zero and pi : All points with coordinates x = r cos (θ) and y = r sin (θ), where r is a constant, lie on a circle with radius r, i.e.  satisfy the equation x2 + y2  = r2.  Create a row vector for θ with the values 0, π/4 , π/2 , 3π/4, π, and 5π/4.
At what point does deviant behavior become criminal behavior : Some view human behavior as the dichotomous categories of "good" and "bad", but there is a continuum of behavior. At what point does deviant behavior become criminal behavior? Is all deviant behavior criminal? Explain your answer in full
Simple random sampling at each stage : Use two-stage sampling, with simple random sampling at each stage, to estimate the mean or total of a population of your choice. In the process of carrying out the survey and making the estimate, think about or discuss with others the following:
Explain tinas gad from the existential perspective : Explain why a humanistic approach would be helpful in treating Tina's GAD - how might you use Rational-Emotive Therapy to treat Tina's GAD?
Assuming the use of a two column general journal : Assuming the use of a two-column general journal, a purchases journal, and a cash payments journal as illustrated in this chapter, indicate the journal in which each of the following transactions should be recorded:

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Predict flood area by using rainfall data

I need help with ANN (Matlab) to predict flood area by using rainfall data and some images that created by ArcGIS.

  Write a matlab code using for loop

Write a MATLAB code using "for" loop to compute y when n = 50,100 and 1000.

  Programme for easter island simulation

The "RATS" program code is given and even if the person does not know RATS, it is very similar so should be able to figure it out.

  Review about using audio weighting in matlab

Write a Literature review about using Audio weighting in Matlab by applying A-filter to the data. Add (graphs and imagines or charts) must also write one or two sentences to describe it

  Develop mathematical models for marine systems

Brushless dc motor based propulsion system for a container vessel model - Mathematical equations (models) for the BLDC Motor

  Write compile and run a hello program

With these mechanical details mastered, everything else is comparatively easy - Write, compile and run a hello program.

  It''s a mechanical engineering project proposal

It's a mechanical engineering project proposal. the program that we using is called "Mat lab". Here are the rules for the project proposal.

  Create matlab functions to plot both your system-dynamics

say a ball of mass m and diameter d is in free-fall from a very high velocity altitude. the governing differential

  Compare two strings to determine if they are the same

Write a statement (or statements) that will compare two strings to determine if they are the same, ignoring whether the characters are upper or lower case.

  Generalize the program below to allow negative integers

Using SML: Generalize the program below to allow negative integers on the input. We assume that negative integers are preceded by the minus sign(-) rather than the tilde (~). Note that we not only have to recognize negative integers but we can no lon..

  Find the laplace transforms

Find the Laplace transforms of the following functions - Find the partial fraction

  Matlab program which will determine your vehicle fuel usage

Create a MATLAB program which will determine your vehicle fuel usage (MPG, miles/gallon) rating for a user defined number of trips ('for' repetition structure).

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