Integrating using quad
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
Hi, I have this really simple problem regarding using quad to integrate a function
for example, I would like to integrate x^2 from 1 to 4 so I would type in:
quad(x^2,1,4)
and this results in an error
then I try:
quad(vectorize(x^2),1,4)
ans =
    21
Perfect!
But vectorizing x^2 resulting in:
vectorize(x^2) ans = x.^2
however typing quad(x.^2,1,4) into matlab still returns an error.
Why is that so?
댓글 수: 0
채택된 답변
  Walter Roberson
      
      
 2012년 1월 6일
        Is x declared as a symbolic variable? quad() cannot process symbolic expressions as the function.
If x is not a symbolic variable, then what is it? vectorize() can only be applied to character strings, inline objects, or function handles.
quad('x^2',1,4)
would be valid syntax, but would run in to problems because quad needs the expression to be able to handle vectors.
quad('x.^2',1,4)
would be valid.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

