Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

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

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M91878793
  • Price:- $70

Priced at Now at $70, Verified Solution

Have any Question?


Related Questions in MATLAB

What comparison of means test was used to answer the

What comparison of means test was used to answer the question

Recitation problems -1 determine the highest real root of

Recitation Problems - 1. Determine the highest real root of f(x) = 2x 3 - 11.7x 2 + 17.7x - 5 using the Newton-Raphson method with at least four iterations. Start with an initial guess of x 0 = 3. 2. Determine the real r ...

Discrete optimisation- solve the following two problems

Discrete Optimisation - Solve the following two problems with both exhaustive enumeration and branch and bound - Problem 1 is a mixed integer linear optimisation problem (the problem has both discrete and continuous vari ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Prepare a 3 - 10 pages long reportprepare a presentation

Prepare a 3 - 10 pages long report Prepare a presentation with 5 - 9 slides. The slides will include introduction (need and similar work), theoretical background (tested neural networks), Data, Results (Comparison of the ...

Suppose that you have used some concept learning algorithm

Suppose that you have used some concept learning algorithm to learn a hypothesis h1 from some training data. You are interested in knowing the accuracy that the hypothesis can be expected to achieve on the underlying pop ...

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As