A function plotting issue with fplot

8 ビュー (過去 30 日間)
John Jarvis
John Jarvis 2019 年 3 月 10 日
コメント済み: John Jarvis 2019 年 3 月 12 日
I want to plot the function vs . I can get the result using fplot, however the x-range () is not
correct. My code is:
v1 = -2.63; v2 = -2.38; gamma=1;
T=[0:0.01:5];
k=pi/2;
l=-k;
w=-2*cos(k);
w1=-2*cos(l);
delta2 = @(T) v2-w+(gamma.*abs(T).^2);
delta1 = @(T) v1-w+gamma*abs(T).^2.*abs(delta2(T)-exp(1i.*k)).^2;
delta21 = @(T) v1-w1+(gamma.*abs(T).^2);
delta11 = @(T) v2-w1+gamma*abs(T).^2.*abs(delta21(T)-exp(1i.*l)).^2;
fplot(@(T) abs((exp(i*k)-exp(-i*k))/(1+(delta2(T)-exp(i*k)).*(exp(i*k)-delta1(T))))^2,[0,5],'g')
hold on
fplot(@(T) abs((exp(i*l)-exp(-i*l))/(1+(delta21(T)-exp(i*l)).*(exp(i*l)-delta11(T))))^2,[0,5],'r')
hold off
The output is alright but the x-axis range seems not correct. The correct figure (ignoring the middle dotted black curve) should look like
What I get is the following
I tried various ways but failed to fix the x-axis issue, what is the problem here?. Any help is highly appreciated. Thanks.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2019 年 3 月 10 日
John - is the output correct? If it is, what is the x-axis issue? Why do you think it should look like the first figure?
John Jarvis
John Jarvis 2019 年 3 月 12 日
Fixed it. It was an error in writing. Thanks.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by