Convert a vector to a scalar

Hello MATLAB users,
I've got a problem during my matlab project. The function that I'm using is 'quad' function.
ISAT = q.*quad(@Integral, 0, t, 1);
But when I run the whole process, it stops at here showing this error message.
"Error using quad (line 66)
The limits of integration must be scalars."
I think it is probably because the 't' value comes from vector NOT a scalar. the t is from the following vector.
x = [1.3:0.1:2.0];
y = [0.5:0.1:1.2];
[X Y] = meshgrid(x, y);
Z = Eff_Tandem(X, Y, Lambda_global).*100 ---> ISAT is inside this function
My question is, is there anyway converting a vector(in this case, t) to a scalar in order to run "quad" function?
Thank you.
Doosan

1 个评论

Is the idea that you need the values of integration at each of the time points? Or do you only need to integrate from the minimum time to the maximum time?

请先登录,再进行评论。

回答(1 个)

data not sufficient, but try this is code:
ISAT = arrayfun(@(x)q.*quad(@Integral, 0, x, 1),t);

1 个评论

Possibly, but that would end up repeating the integration over the parts that had already been done. To get it done interval by interval,
t1 = [0 t];
ISAT = arrayfun(@(N)q.*quad(@Integral, t1(N), t1(N+1), 1), 1:length(t));

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by