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 Comment

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?

Sign in to comment.

Answers (1)

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

1 Comment

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));

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 7 Jul 2012

Community Treasure Hunt

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

Start Hunting!