Wien's law and Plancks law for black-body radiation is compared and plotted.
Sathyanarayan Rao (2021). Blackbody Radiation Spectrum from Wien's Law and Planck's law (https://www.mathworks.com/matlabcentral/fileexchange/48253-blackbody-radiation-spectrum-from-wien-s-law-and-planck-s-law), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Just wanted to re-affirm that this script did exactly what I expected and Stephan Suckow's suggestions worked as well.
A couple minor suggestions:
1.) Before entering the for loop, initialize the size of I1 and I2 using the following:
I1 = zeros(length(Lam),length(T));
I2 = zeros(length(Lam),length(T));
2.) Change for loop to iteration variable and range to:
for ii = 1:length(T)
The first suggestion may help speed things up. The second one does two things 1) change the for loop iteration variable from i to ii (MATLAB uses i for imaginary numbers) and 2) allows one to change the length of T and not have to modify the for loop range.
Thank you.
Does exatly what it claims. Minor improvement suggestion:
Line 33: plot(Lam,I1(:,i),'b','linewidth',2)
Line 42: line([1.2e-5 1.4e-5], [5e8 5e8],'color','b','linewidth',2)
This way the legend matches the line color for all temperatures in newer Matlab versions.