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 commentaire

Walter Roberson
Walter Roberson le 7 Juil 2012
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?

Connectez-vous pour commenter.

Réponses (1)

Andrei Bobrov
Andrei Bobrov le 7 Juil 2012

0 votes

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

1 commentaire

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by