필터 지우기
필터 지우기

quad with parameter

조회 수: 2 (최근 30일)
Matus
Matus 2012년 3월 18일
Edit Delete quad with parameter Matus asked less than a minute ago
Hi, i try to solve integral with quad and i want to use a parameter. when i put into matlab this code:
quad('cos(t.*314).^2',0,1)
n=2; %parameter
quad('cos(t.*314).^n',0,1,[],[],n)
the solution is not equal. Can you help me please. Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2012년 3월 18일
You cannot pass in parameters the way you are attempting to in the second form. You need to use an anonymous function.
n = 2;
quad(@(t) cos(t*pi).^n, 0, 1)
Please review the quad documentation and notice that there is no possible parameter after "trace", and read the part about Parameterizing Functions.
  댓글 수: 1
Matus
Matus 2012년 3월 18일
Thank you Walter.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by