How do I define this integral function?
1 view (last 30 days)
Show older comments
Attached is a pdf of the function I am trying to define. t' is the integral variable (which in the code I name x).
ω
, s,
μ
are variable parameters that will take a range of values that the user chooses. AT is a vector of 12054 temperatures which, for simplicity, we can consider all values in the vector as 1. My function so far is this:
% Lambda needs to contain all the values for each value of t.
functionintegral = lamb(s,om,mu,AT)
t = max(s)+1:numel(AT);
forti = 1:numel(t)
fun1 = @(x) om.^abs(x-s).*AT(t(ti)-x);% Numerator
q = @(x) integral(fun1,0,t(ti));% Integral of the numerator
fun2 = @(x) om.^abs(x-s);% Denominator
p = @(x) integral(fun2,0,t(ti));% Integral of the denominator
lambda = mu + q/p;% Function seen in pdf
end
I run this function using this script:
% Here I would load AT but for simplicity let it be vector of 1's.
s = 0:60;% lag range
om = 0.1:0.1:1;% decay rate range
mu = 1:10;% baseline rate range
Ns =元素个数(年代);
Nom = numel(om);
Nmu = numel(mu);
nll = nan(Ns,Nom,Nmu);
for如果= 1:Ns
omi = 1:Nom;
mui = 1:Nmu;
integral(si,omi,mui) = lamb(s(si),om(omi),mu(mui),AT);
end
I end up with the error:
Errorusing/
Argumentsmust be numeric, char, orlogical.
% This error is for the final line in the for loop in the function.
If anyone could help me with this function it would be much appreciated, thank you.
0 Comments
Accepted Answer
David Goodmanson
on 29 Jul 2021
艾德ited:David Goodmanson
on 29 Jul 2021
你好LT,
fun1 = @(x) x.^2
q1 = @(x) integral(fun1,0,4)
q2 = integral(fun1,0,4)
q1 = function_handle withvalue:
@(x)integral(fun1,0,4)
q2 = 21.3333
I assume that you want a numerical result for q, but the extra @(x) creates a function handle instead.
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!