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 Kommentar

Walter Roberson
Walter Roberson am 7 Jul. 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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 7 Jul. 2012

0 Stimmen

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

1 Kommentar

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Jul. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by