Matlab computer assignment

profilehadi05ali
EE341MATLABComputerAssignmentrev22.pdf

EE 341 MATLAB Computer Assignment Prof. Aaron Scher Guidelines

• You are to work independently. This is not a team assignment. Feel free to help your fellow classmates understand principles and concepts, but please do not directly share significant portions of your MATLAB code.

• For this assignment, you will create a PowerPoint presentation, save it as a PDF, and upload it to Blackboard.

• All submitted plots should be easy to see and well-labeled. Title Slide

• Slide 1: Title slide with your name, student ID number, date, lab name, class number/title.

Plotting the E-field (40%)

• An important skill in electromagnetics is to visualize and sketch the fields. Consider an electric field projected on the x-y axis given by the following equation:

𝑬""⃗ (𝑥,𝑦) = 𝒙+(−𝑥) + 𝒚+(−𝑦) (1)

• Manually, compute the following and present your computations and solutions in

Slides 2-4: o 𝑬""⃗ (𝑥,𝑦) at (𝑥,𝑦) = (1,1) o 0𝑬""⃗ (𝑥,𝑦)0 at (𝑥,𝑦) = (1,1) o ∇ ∙ 𝑬""⃗ (𝑥,𝑦) at (𝑥,𝑦) = (1,1) o ∇ × 𝑬""⃗ (𝑥,𝑦) at (𝑥,𝑦) = (1,1)

• Sketch by hand the field 𝑬""⃗ (𝑥,𝑦) and present in Slide 5. Your sketch should span the range 𝑥 = −2 to + 2 and 𝑦 = −2 to + 2. Be sure your sketch is clear, well-labeled (remember to label the axes), and easy to read.

• In MATLAB (or Octave) use the meshgrid and quiver functions to create a quiver plot of the vector field E. Your plot should span the range 𝑥 = −2 to + 2 and 𝑦 = −2 to + 2. Please include your name in the title of the plot (e.g. title('Jane Doe - Quiver Plot')). Be sure your plot is clear, well-labeled, and easy to read. Present your plot in Slide 6. Present your MATLAB code in Slides 7 – 9. Leave unused slides blank.

Numerically computing E-fields (60%)

• Consider an infinite line charge on the z-axis with linear charge density 𝜌9 = 2 [µC/m].

• Recall that the analytical equation for the E-field produced by a line charge on the z- axis with charge density 𝜌9 at point P(x,y,z) is:

𝐄 = 𝐫A BC DEFGH

(1)

where 𝐫A is the radial unit vector in the cylindrical coordinate system, and 𝑟 = J𝑥D + 𝑦D is the radial distance from the z-axis to the point P(x,y,z), as shown in the hand-sketch in Figure 1 below.

Figure 1. Hand-sketch of line charge on z-axis and E-field.

• Using eq. (1), calculate the E-field produced by the line charge at observation point P(2,3,4) in both cylindrical and rectangular coordinate systems. Present your answers in Slide 10. The basic form of your answers should be:

𝐄 = 𝐫A𝐸H [V/m] (cylindrical coordinate system)

𝐄 = 𝐱A𝐸M + 𝒚+𝐸N [V/m] (rectangular coordinate system)

Your job is to find numerical values of 𝐸H and 𝐸M and 𝐸N in the expressions above. Remember to watch your units. The units for the E-field should be in V/m. • Write a MATLAB program to numerically verify the answer above. To do this, replace

the infinite line charge with a sufficiently long fine line charge. The new line charge

will have a length equal to one hundred times of the distance from the observation point to the line charge, and its center is located at z = 4, i.e. at the center point C (0, 0, 4) as shown in Figure 2. Divide the line charge into many equal little segments of length ∆𝐿. Treat each little segment as a point charge ∆𝑄 = 𝜌9∆𝐿 (each positioned in the center of the corresponding line segment), and evaluate the electric field generated by each line segment at observation point P(2,3,4). Finally, evaluate the summation of the electric fields generated by all those little line segments. The summation should be very close to the electric field generated by the infinite linear charge. This numerical approach can be summarized by the mathematical expression:

𝑬""⃗ (at point 𝑃) = W𝑬""⃗ X

Y

XZ[

= W ∆𝑄

4𝜋𝜖_|𝑹X|b 𝑹X

Y

XZ[

= W 𝜌9∆𝐿,

4𝜋𝜖_|𝑹X|b 𝑹X (2)

Y

XZ[

where 𝑬""⃗ X is the electric field generated by the ith segment, 𝑹X is the vector from the ith segment to the observation point, ∆𝑄is the charge of a single segment, ∆𝐿 is the length of the segment, and n is the total number of segments.

• Present your numerically calculated E-field solution in Slide 11. In this slide, also present the percent difference between the analytic and numeric results. If everything is correct, the percent difference should be small.

• In Slides 12 and onwards, present your MATLAB program you wrote to numerically calculate the E-field and complete the steps above.

Figure 2 Discretizing the problem for numerically solving with MATLAB

z

C (0,0,4)