[scilab-Users] Scilab does not working as expected

Samuel GOUGEON Samuel.Gougeon at univ-lemans.fr
Sun May 8 18:22:13 CEST 2011


  Hello,

----- Message d'origine -----
De : Egidijus Kamarauskas
Date : 07/05/2011 19:41:
> Hello
> excuse me for my poor English.
> I tried to calculate a Sun spectra from black body formula - 
> http://en.wikipedia.org/wiki/Planck%27s_law
> as function of frequency.
> Here is my code:
>
> ny1=[1.5:1.5:30];
> x=ny1*10^14;
> k=1.38*10^(-24);
> T=5800;
> h=6.63*10^(-34);
> c=3*10^(17);
> deff('[y]=f(x)',['y=(2*h*x^3)/(c^2)*(exp((h*x)/(k*T))-1)^(-1)']);
> fplot2d( log10(x) , log10(f), style=-1 )
>
> .../...
> But I can not understand, why I always become a error : Function not defined 
> for given argument type(s).
You cannot get the log10 of a function (by itself) but of its results.
By the way, you were providing log10(x) to f(), instead of x.
A proper way to do what you are expecting is by changing the 2 last lines in:

deff('[y]=f(x)',['y=(2*h*x^3)/(c^2)./(exp((h*x)/(k*T))-1)']);
plot2d("ll",x ,f(x), style=-1 )

or in a more documented way:

nu = (1:300)*1e13;    // [Hz]
k = 1.38e-23;        // Boltzmann [J/K]
T = 5800;            // [K]
h = 6.63e-34;        // [J.s]
c = 3e8;             // [m/s]
clf
plot2d("ll",nu ,2*h/c^2*nu^3 ./(exp(h*nu/(k*T))-1))
xtitle("Black body emission for T = 5800 K","Frequency [Hz]",..
         "$\mbox{Spectral luminance }[W/m^2/sr/Hz]$")

HTH
Samuel




More information about the users mailing list