What do you do when your codes are correct but the graph does not show And do you add other graphs to be on same graph

6 件のコメント

Star Strider
Star Strider 2017 年 5 月 30 日
If ‘the codes are correct but the graph does not show’, the codes are not correct.
If we could see the code we might be able to find and fix the problem.
Samuel Suakye
Samuel Suakye 2017 年 5 月 30 日
編集済み: Steven Lord 2017 年 5 月 30 日
figure
clear;
clc;
delta=[0.0259, 0.0518, 0.0776, 0.1035, 0.1293]*10;
delta1=0.01:0.09:0.5;
hbar=6.5821220*10e-16;
k=8.617385*10e-5;
T=300;
d=100*10e-10;
m = 9.1093897*10e-31;
v = 2.8*10e8;
c = 3.0*10e8;
wp = 10e12;
w = 0.7071;
gamma = (1-((v^2)/(c^2)))^-0.5;
delta2= delta1./(k*T);
wo=(wp^2*m*d^2*delta1.*besseli(1,delta2))/(hbar^2*besseli(0,delta2)).^0.5;
delta3=delta./(k*T);
therta = asind(1-(w^2/wo^2))^0.5;
wb = gamma*wo*cosd(therta);
rho=(wb^2* hbar^2 *besseli(0,delta3))/(wp^2*m*d^2 *k*T*besseli(1,delta3));
plot(delta3,rho,'LineWidth',1.5)
xlabel('\Delta^*')
ylabel('E_b/E_s')
%mesh(Vd,wq,real(y))
hold on
grid on
[SL: Edited to apply code formatting. Samuel, in the future when you post code please use the "{}Code" button to make it easier to read. Thanks.]
Star Strider
Star Strider 2017 年 5 月 30 日
Your vector lengths must have the same row and column sizes. Since I have no idea what you are doing, I will let you sort that.
You also need to use element-wise operations. See the documentaiton on Array vs. Matrix Operations (link) for the details.
Samuel Suakye
Samuel Suakye 2017 年 5 月 31 日
Thank you.
But how do you make the curve smooth. Besides how do you plot different graphs on the same graph and same codes. Eg. Like when d=150*10e-10 by not writing different codes for it.
Stephen23
Stephen23 2017 年 5 月 31 日
編集済み: Stephen23 2017 年 5 月 31 日
"What do you do when your codes are correct"
You change your perspective that your code is "correct". Your code is not "correct", in fact it is buggy. When you sit and think "my code is correct" then you will never get any better at looking for bugs, and understanding how to fix them. You need to learn to actually look at your code, and not rely on what you want/imagine/wish your code were doing.
Samuel Suakye
Samuel Suakye 2017 年 6 月 6 日
編集済み: Stephen23 2017 年 6 月 6 日
figure
clear;
clc;
delta=[0.0259, 0.0518, 0.0776, 0.1035, 0.1293]*10;
%delta=0.01:0.09:0.5;
delta1=0.01:0.1:0.5;
hbar=6.5821220*10e-16;
k=8.617385*10e-5;
T=300;
d=[100 150 200]*10e-10;
m = 9.1093897*10e-31;
v = 2.8*10e8;
c = 3.0*10e8;
wp = 10e12;
w = 0.7071;
gamma = (1-((v^2)/(c^2)))^-0.5;
delta2= delta1./(k*T);
figure
hold on
for i = 1:length(d)
wo=(wp^2*m*d(i)^2*delta1.*besseli(1,delta2))./(hbar^2*besseli(0,delta2)).^(0.5);
delta3=delta./(k*T);
therta = asind(1-(w.^2./wo.^2)).^0.5;
wb = gamma.*wo.*cosd(therta);
%wb^2=2
rho=(hbar^2.*2.*besseli(0,delta3))./(wp^2*m*d(i)^2*k*T.*delta3.*besseli(1,delta3));
plot(delta3,rho,'LineWidth',1.5)
end
xlabel('\Delta^*')
ylabel('E_b/E_s')
hold on
grid on
How do I make the graph smoother

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

 採用された回答

KSSV
KSSV 2017 年 5 月 31 日
編集済み: KSSV 2017 年 5 月 31 日

1 投票

Change this line:
rho=(wb^2* hbar^2 *besseli(0,delta3))/(wp^2*m*d^2 *k*T*besseli(1,delta3));
to
rho=(wb^2* hbar^2 *besseli(0,delta3))./(wp^2*m*d^2 *k*T*besseli(1,delta3));
You are supposed to do element by element by division. Now it shows plot.
If you have multiple d's, you can follow like this:
clear;
clc;
delta=[0.0259, 0.0518, 0.0776, 0.1035, 0.1293]*10;
delta1=0.01:0.09:0.5;
hbar=6.5821220*10e-16;
k=8.617385*10e-5;
T=300;
d=[100 150]*10e-10;
m = 9.1093897*10e-31;
v = 2.8*10e8;
c = 3.0*10e8;
wp = 10e12;
w = 0.7071;
gamma = (1-((v^2)/(c^2)))^-0.5;
delta2= delta1./(k*T);
figure
hold on
for i = 1:length(d)
wo=(wp^2*m*d(i)^2*delta1.*besseli(1,delta2))/(hbar^2*besseli(0,delta2)).^0.5;
delta3=delta./(k*T);
therta = asind(1-(w^2/wo^2))^0.5;
wb = gamma*wo*cosd(therta);
rho=(wb^2* hbar^2 *besseli(0,delta3))./(wp^2*m*d(i)^2 *k*T*besseli(1,delta3));
plot(delta3,rho,'LineWidth',1.5)
end
xlabel('\Delta^*')
ylabel('E_b/E_s')
%mesh(Vd,wq,real(y))
hold on
grid on
You need to check your code, rho is complex.

5 件のコメント

Samuel Suakye
Samuel Suakye 2017 年 5 月 31 日
Please how do you make the graphs drawn smooth
KSSV
KSSV 2017 年 5 月 31 日
You need to increase the number of points I delta3.
Samuel Suakye
Samuel Suakye 2017 年 6 月 1 日
Still not smooth
Samuel Suakye
Samuel Suakye 2017 年 6 月 6 日
figure clear; clc; delta=[0.0259, 0.0518, 0.0776, 0.1035, 0.1293]*10; %delta=0.01:0.09:0.5; delta1=0.01:0.1:0.5; hbar=6.5821220*10e-16; k=8.617385*10e-5; T=300; d=[100 150 200]*10e-10; m = 9.1093897*10e-31; v = 2.8*10e8; c = 3.0*10e8; wp = 10e12; w = 0.7071; gamma = (1-((v^2)/(c^2)))^-0.5; delta2= delta1./(k*T); %% figure hold on for i = 1:length(d) wo=(wp^2*m*d(i)^2*delta1.*besseli(1,delta2))./(hbar^2*besseli(0,delta2)).^(0.5); delta3=delta./(k*T); therta = asind(1-(w.^2./wo.^2)).^0.5; wb = gamma.*wo.*cosd(therta); %wb^2=2 rho=(hbar^2.*2.*besseli(0,delta3))./(wp^2*m*d(i)^2*k*T.*delta3.*besseli(1,delta3)); plot(delta3,rho,'LineWidth',1.5) end %% xlabel('\Delta^*') ylabel('E_b/E_s') hold on grid on
Samuel Suakye
Samuel Suakye 2017 年 6 月 6 日
Still not smooth

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series Events についてさらに検索

タグ

質問済み:

2017 年 5 月 30 日

編集済み:

2017 年 6 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by