필터 지우기
필터 지우기

Quad Function Error for Integrals

조회 수: 1 (최근 30일)
Adriel Martinez-Alvarez
Adriel Martinez-Alvarez 2017년 4월 7일
댓글: David Goodmanson 2017년 4월 7일
Hello, I have spent the last 2 hours trying to figure out why the quad function (required to use instead of integral function by my professor) is not working. MatLab just tells me there is an error with my code but does not go into any specifics into what the error might be, making it very difficult & frustrating to debug. Anyways, I need to use the quad function to calculate the following integrals. The first equation y1 works, but y2 & y3 come up with an error. How do I fix this?
y1 = quad('x.^2 +2*x+3',0 , 3)
y2 = quad('(.5*x.^3)/(1+2*sqrt(x))', 2, 10)
y3 = quad('.5 + ((cos(1.2*x))/((x+2)^2))', 0, 9)

채택된 답변

David Goodmanson
David Goodmanson 2017년 4월 7일
Hello Adriel, you are missing some dots to make element-by-element division and exponentiation happen
y1 = quad('x.^2 +2*x+3',0 , 3)
y2 = quad('(.5*x.^3)./(1+2*sqrt(x))', 2, 10)
^
y3 = quad('.5 + ((cos(1.2*x))./((x+2).^2))', 0, 9)
^ ^
  댓글 수: 2
Adriel Martinez-Alvarez
Adriel Martinez-Alvarez 2017년 4월 7일
Ah, I see. Thank you for your quick answer. I can't believe I spent so much time on something so simple.
David Goodmanson
David Goodmanson 2017년 4월 7일
Yes, I think we have all been there. You look at something 25 times and never see what's hiding in plain sight.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by