Matlab code - probably a simple mistake
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to calculate kx, and ky. The conductivity in the x and y direction. The graph is supposed to look like a nice upwards curve, however mine fluxuates up and down(like a wave). I have checked my formulas, by inserting the values into the equation for L, the values of kx and ky appear to be correct. It seems as though the graphing part does not work tho.
I am going from L is 30 to 140, increments of 10. This is the only variable that changes. Here is my code:
clear
clc
% Constants
mfp = 31; % mean free path (nm)
k = 316.72; % conductivity (W / m*k)
% Equations
Lmax = 140;
dL=10;
L=30;
while L<=Lmax
kx(L)=k*(1-((2*mfp)/(3*3.14*L)));
ky(L)=k*(1-(mfp/(3*L)));
L= L+dL;
end
plot(kx,'-'),hold on, plot(ky,'--'), hold on, plot(k);
title(['Conductivity ']);
xlabel('Thickness (nm)','FontSize',14);
ylabel('Conductivity','FontSize',14);
leg1=legend('kx','ky');
0 Commenti
Risposte (1)
Paulo Silva
il 2 Set 2011
You are just looking for plot(kx,ky) not all those plots
Also the calculations generate several zero values, that's why plot(kx,ky) shows many lines, you can plot just their values plot(kx,ky,'*') or ignore all the zeros and connect the points with one line:
clear
clc
% Constants
mfp = 31; % mean free path (nm)
k = 316.72; % conductivity (W / m*k)
% Equations
Lmax = 140;
dL=10;
L=30;
while L<=Lmax
kx(L)=k*(1-((2*mfp)/(3*3.14*L)));
ky(L)=k*(1-(mfp/(3*L)));
L= L+dL;
end
kx(~kx)=[];
ky(~ky)=[];
plot(kx,ky);
title(['Conductivity ']);
xlabel('Thickness (nm)','FontSize',14);
ylabel('Conductivity','FontSize',14);
5 Commenti
Paulo Silva
il 2 Set 2011
I don't know where the zeros are, I just noticed that they are messing up the result of the plot function and yes the result does look like plot(x,sqrt(x))
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!