solve integral using ode45 (by derivative)
Show older comments
Hi!
I've got a task that requires me to solve the following integral using ode45 by derivating the integral with the upper limit as "t". I don't seem to understand how to solve this, other than using the command "integral" (which I'm not allowed to do).

I've been given m_e, but my ODE45 attempt doesn't seem to work, and I don't understand why. The code below is what I've come up with.
planckfunnew=@(t,T)planck(lambda,T);
[tsome,ssome]=ode45(planckfunnew,[0 1],[4.*10.^-7;100]);
% plot(ssome(:,1),ssome(:,2))
function me=planck(lambda,T)
h=6.6256e-34;
c=2.9979e8;
k=1.3805e-23;
a=2*pi*h*c^2;
b=h*c/k./lambda./T;
me=a./lambda.^5./(exp(b)-1);
I'm not that sure of how to define the function, which I'm supposed to insert in the ode45 line.
I'm grateful for any help that I recieve!
Accepted Answer
More Answers (2)
Brent Kostich
on 27 May 2020
It appears you are working with the Stephan-Boltzmann Law. However, I think the syntax in your "planck" function may be a bit off. In any case, here is what I think you are trying to accomplish. The main function accepts a range of temperature values, used to evaluate your given equations.
function [] = wavelength_fractal(T)
%{
T should typically be a vector input of temperature range
%}
%% Calculating Spectral Intensity
% pre-allocating a vector of length T
M_s = zeros(1, length(T));
for i = 1:length(T)
% numerical integration "planck" function
[~, y] = ode45(@(lambda, y) planck(lambda, T(i)), [4e-7 7e-7], 0);
M_s(i) = y(end);
end
%% Using Stefan-Boltzmann constant
stef_bolt = 5.67e-8;
M_e = stef_bolt*T(i)^4;
%% Calculating fraction
wave_frac = M_s/M_e;
%% Plotting Output
figure(1)
plot(T, wave_frac)
grid
function m_e = planck(lambda, T)
h = 6.6256e-34;
c = 2.9979e8;
k = 1.3805e-23;
a = 2*pi*h*c^2;
b = (h*c)/(k*lambda*T);
m_e = a/(lambda^5*(exp(b)-1));
So then by entering a command line prompt of:
wavelength_fractal(linspace(100,10000))
The result should be:

You of course can add your own figure title, axis labels, etc. to spruce it up. Cheers!
2 Comments
John D'Errico
on 27 May 2020
Thanks. I'll completely agree that I have no idea what the real equations needed here are, only that I worked from what the OP provided.
Brent Kostich
on 28 May 2020
I hear you, your solution was completely sound to that end. At one point this thread contained more information about the OP's problem, but I think it has since been taken down. My solution was considering that additional information.
Ameer Hamza
on 27 May 2020
Edited: Ameer Hamza
on 27 May 2020
Try this
M = @(T) integral(@(lambda) planck(lambda,T), 4e-7, 7e-7);
s = M(10000); % T=10000
function me=planck(lambda,T)
h=6.6256e-34;
c=2.9979e8;
k=1.3805e-23;
a=2*pi*h*c^2;
b=h*c/k./lambda./T;
me=a./lambda.^5./(exp(b)-1);
end
Result
>> s
ssome =
1.8551e+08
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!