フィルターのクリア

On plot divisions and possibly numerical resolution

1 回表示 (過去 30 日間)
Alvin
Alvin 2017 年 10 月 11 日
コメント済み: Alvin 2017 年 10 月 11 日
clear
C1 = linspace(0,1000,1000);
C2 = 49.28;
k1 = 0.5;
k2 = 5;
n1 = 0;
n2 = 0;
nm = 0;
D = -1;
O = 1;
gam = 0.01;
alph = 0;
for ii=1:length(C1)
w = linspace(-10,10,5500);
k1eff = k1.*(1+C2);
TA = w./(k1eff./2);
TB = w./(gam./2);
Y1 = (-2.*1i.*sqrt(C1(ii)))./(sqrt(gam).*((1+C2).*(1-1i.*TA).*(1-1i.*TB)+C1(ii)));
Y2 = (-2.*sqrt(C1(ii).*C2))./(sqrt(gam).*((1+C2).*(1-1i.*TA).*(1-1i.*TB)+C1(ii)));
Y3 = (2.*(1+C2).*(1-1i.*TA))./(sqrt(gam).*((1+C2).*(1-1i.*TA).*(1-1i.*TB)+C1(ii)));
AY1 = abs(Y1).^2;
AY2 = abs(Y2).^2;
AY3 = abs(Y3).^2;
Sbb = 2*pi.*(AY1.*(n1 + 0.5) + AY2.*(n2 + 0.5) + AY3.*(nm + 0.5));
A = trapz(w,Sbb);
AA(ii)=A
%{
figure(1)
plot(TB,Sbb)
%ylim([0,30])
set(gca,'FontSize',13)
xlabel('\theta_B')
ylabel('S_{bb}')
drawnow limitrate
%ylim([0,5])
%}
end
figure(1)
plot(C1,AA)
set(gca,'FontSize',13)
xlabel('C_2')
ylabel('n_{b} + 1/2')
title('\Gamma_m = 0.01, \kappa_1 = 0.5, \kappa_2 = 5,\Delta = -1, \Omega_m = 1, C_2 = 49.28, n_1 = 0, n_2 = 0, n_m = 0, \alpha = 0')
%xlim([0,100])
Upon compiling the code above, a plot with a tiny peak at about Y=19.73 will be displayed. If one would use the Data Cursor and trace along the plot, it can be seen that the Y values do not change accordingly as X increases. This is clearly not true, since you can tell from the Workspace of my AA array that it's increasing (albeit slowly). Does anyone know what the issue is? Is it a numerical resolution issue with Matlab?
Thank you in advance.

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 11 日
The default data cursor display function only displays 4 digits.
Right click on the datatip display and choose "Edit text update function". In the three num2str() calls, change the 4 to something larger -- 6 or 7 perhaps. Click on the "save and close" at the bottom. Choose a location and allow it to be saved. Now notice that the number of digits has increased on the data cursor.
Suppose you saved as NewCallback.m . Then to make it active by program control,
dcm = datacursormode();
set(dcm, 'UpdateFcn', @NewCallback);
  1 件のコメント
Alvin
Alvin 2017 年 10 月 11 日
That worked! Thank you very much!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by