quad with parameter

1 Ansicht (letzte 30 Tage)
Matus
Matus am 18 Mär. 2012
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Mär. 2012
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 Kommentar
Matus
Matus am 18 Mär. 2012
Thank you Walter.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Special Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by