Why is my graph not right?

조회 수: 5 (최근 30일)
chris henkel
chris henkel 2017년 12월 18일
댓글: Star Strider 2017년 12월 19일
Im trying to make this graph. I was unable to find symbols so I just used numbers for most of the equation (the first one). I need to plot (delta w). Ive added an attachment with the equation and what the graph should look like, if someone could help. This is what I have tried but I keep getting the wrong curve:
>> w0 = 10.^14
w0 =
1.0000e+14
>> y = 5*10.^12
y =
5.0000e+12
>> e3 = 12.1
e3 =
12.1000
>> e4 = 10
e4 =
10
>> w = 50*10.^12:10.^12:150*10.^12;
>> e1 = ((e4)-((e3)-(e4)))*(((2*(w0))*(w))/(((4*((w).^2))+((y).^2))));
>> plot(w,e1)

채택된 답변

Star Strider
Star Strider 2017년 12월 19일
Since this was due three weeks ago, I decided to code it myself for fun. There actually seem to be some errors in the homework assignment either in the constants or the range of the independent variable. It may also be that there should be an offset, perhaps something like ‘(dw - w0)’ or some such that would centre the independent variable appropriately to reproduce the plots as posted. (I just experimented with the independent variable until I got the plots to work.)
This produces the plots:
dw = linspace(-25, 25) * 1E+12;
w0 = 1E+14;
gma = 5E+12;
est = 12.1;
einf = 10;
e1 = @(dw) einf - (est - einf)*2*w0*dw./(4*dw.^2 + gma.^2);
e2 = @(dw) (est - einf) * gma*w0./(4*dw.^2 + gma.^2);
n = @(dw) sqrt(e1(dw) + sqrt(e1(dw).^2 + e2(dw).^2))/sqrt(2);
kpa = @(dw) sqrt(-e1(dw) + sqrt(e1(dw).^2 + e2(dw).^2))/sqrt(2);
figure(1)
subplot(2,2,1)
plot(dw, e1(dw))
ylabel('\epsilon_1')
grid
subplot(2,2,3)
plot(dw, e2(dw))
ylabel('\epsilon_2')
xlabel('\omega')
grid
subplot(2,2,2)
plot(dw, n(dw))
ylabel('\it{n}')
grid
subplot(2,2,4)
plot(dw, kpa(dw))
ylabel('\kappa')
xlabel('\omega')
grid
Experiment to get the result you want.
  댓글 수: 2
chris henkel
chris henkel 2017년 12월 19일
thank you, that worked
Star Strider
Star Strider 2017년 12월 19일
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by