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
Walter Roberson
2012년 7월 7일
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개)
Andrei Bobrov
2012년 7월 7일
data not sufficient, but try this is code:
ISAT = arrayfun(@(x)q.*quad(@Integral, 0, x, 1),t);
댓글 수: 1
Walter Roberson
2012년 7월 7일
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!