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

  Simulate an atm machine and provide the code

Simulate an ATM machine and provide the code. I have the answer already but i do not understand it; I need expert to guide through it step by step. thanks!

  How to cipher on matlab the message consisting eight symbols

How to cipher on Matlab the message consisting eight symbols. At first the message shares on blocks. Then in each of blocks shift of symbols is carried out.

  Plot the signal representing the tones versus time

Plot the signal representing the tones versus time - determine the number of tones and set break points to separate the individual tones.

  Determines which member has the largest magnitude force

Determines which member has the largest magnitude force. Reports to the Command Window which member has the largest magnitude force and the value of the force in that member.

  Compare filter with that given by matlab function bilinear

Compare your filter with that given by the Matlab function ‘bilinear' for the same conditions. Manually design a second order digital filter, with the damping ratio given in the table.

  Determine the size for variables used in matlab program

If b=3, a=6 how many loops would the given program do? what will be the out put for z(4)? what would be size (in rows and columns) for variables z, i and b?

  Write a matlab script m-file to play a guessing game the

write a matlab script m-file to play a guessing game. the user will try to guess a number between 1 and 100. your

  Considering the integral

Using the code, generate the first 40 terms: show the result using the format long e. Comment about your results.

  Design a controller which regulates flow

Design a controller which regulates flow and compensate pressure to my desire value in simscape.

  Write matlab scripts

Write MATLAB scripts for to accept two numbers from the user; Display all prime numbers between these two numbers.

  When a fast-breeder reactor is shut down quickly the

when a fast-breeder reactor is shut down quickly the temperature of the surface of a number of components drops from

  Derive finite difference equations for all interior nodes

Derive finite difference equations for all the interior nodes - develop a MATLAB code, and determine temperatures at all interior nodes.

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