0% found this document useful (0 votes)
2 views3 pages

Assignmen 1

Uploaded by

faiq00goraya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Assignmen 1

Uploaded by

faiq00goraya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Problem 3.

Two distances are required to specify the location of a point relative to an origin in two-
dimensional space (Fig. P3.6):

The horizontal and vertical distances (x, y) in Cartesian coordinates.


The radius and angle (r, θ ) in polar coordinates.

It is relatively straightforward to compute Cartesian coordinates (x, y) on the basis of


polar coordinates (r, θ ). The reverse process is not so simple. The radius can be
computed by the following formula:

r  x2  y2

If the coordinates lie within the first and fourth coordinates (i.e., x > 0), then a simple
formula can be used to compute θ:
 y
θ  tan1  
 x
The difficulty arises for the other cases. The following table summarizes the
possibilities:

Write a well-structured M-file using if...elseif structures to calculate r and θ as a


function of x and y. Express the final results for θ in degrees. Test your program by
evaluating the following cases:
Problem 3.11

The volume V of liquid in a hollow horizontal cylinder of radius r and length L is related
to the depth of the liquid h by

  r h  
V  r2 cos1    (r h) 2rh  h  L
2

  r  

Develop an M-file to create a plot of volume versus depth.

Here are the first few lines:


function cylinder(r, L, plot_title)
% volume of horizontal cylinder
% inputs:
% r = radius
% L = length
% plot_title = string holding plot title

Problem 3.22

Develop a function to produce an animation of a particle moving in a circle in Cartesian


coordinates based on radial coordinates. Assume a constant radius, r, and allow the
angle, θ, to increase from zero to 2π in equal increments. The function’s first lines
should be

function phasor(r, nt, nm)


% function to show the orbit of a phasor
% r = radius
% nt = number of increments for theta
% nm = number of movies
Test your function with
phasor(1, 256, 10)

You might also like