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

  Step response of the position servo system

Use MATLAB to plot the step response of the position servo system for values of the gain K=0.5, 1.0, 2.0 below is possible data code

  Write a matlab function newtonraphson

Write a MATLAB function newtonRaphson(fx, x0, sigfig, maxIT) that will return a root of the function f(x) near x=x0 using the Newton-Raphson method, where sigfig is the accuracy of the solution in terms of significant figures

  Viewing the guided solutions for stormy attaway''s intro

I subscribed for a 7 day study membership trial 2 days ago. I have been viewing the Guided solutions for Stormy Attaway's Intro to programming in Matlab 2nd edition

  Calculate the coefficients a of after two finite barrier

For the following system, use Matlab to: Calculate the coefficients A' of ?? after two finite barriers via transfer matrix approach. Calculate transmission probability (T=|A'|2/|A|2) in case of E>V. Choose E = 4 eV, V = 2 eV, a = 0.1 nm, b = 0.3 nm

  Elementary numerical methods and programming

Project involes determining the dynamics of the double pendulum with a sliding base. Each link is assumed to be of square cross section - MECH 3010: Elementary Numerical Methods and Programming

  Plot the lines using the inputted vector of x values and x

Write a function named solveSystem that has three inputs: two vectors consisting of coefficients [a b c] of two line equations of the form ax + by = c and a vector of x values.

  Plot the angular velocity of the pendulum

Plot the angle of the pendulum as calculated from all three ODE solver methods on a single plot, ensuring that the plot is titled, all axes are labelled, units are indicated, and the legend for each solver displayed in Best configuration.

  Find the average value and the power of signal

Find the average value and the power of this signal by integrating 1/T0 v(t) and 1/T0 v2(t) respectively in the time domain, over one period. Your answer must be expressed in terms of fc and Ac only.

  Create the oxygen dissociation curve

Create the oxygen dissociation curve, perform a linear regression on the experimental data using built-in Matlab function, and plot your best-fit model with the data to show that linearity exists.

  Design a matlab application

Design a MATLAB application that has the following features under single-phase conditions:

  Write a script that will loop through values of n

Write a script that will loop through values of n until the difference between the approximation and the actual value is less than 0.0001.

  Use the definition for the laplacian in the discrete case

Show that subtracting the Laplacian from an image is proportional to unsharp masking. Use the definition for the Laplacian in the discrete case to derive the equivalence relation, constant weighting factors should not affect your conclusion.

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