View Full Version : Matlab help .. problems in finding integrals
jaspreet85
31 May 2006, 3:18pm
hi all,
i need to find the integral of a complicated function..using int,matlab says it cannot find it..tried using quad but for that i may have to send some parameters to the function..does neone knows how to send parameters when using quad..
as in quad(@myfun,a,b,parameters..)
whr a b are limits..and parameters are some of which i have to send...
ne help???
shwaip
31 May 2006, 3:53pm
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/quad.html
if you want more help, we need more details.
jaspreet85
31 May 2006, 4:09pm
well..i want to use the quad fn. but apart from sending the function handle and the limits as arguments, i also need to send some more parameters.I dont know if that is allowed and if allowed how to do that??
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/quad.html
if you want more help, we need more details.
shwaip
31 May 2006, 4:18pm
what other parameters?
jaspreet85
31 May 2006, 4:32pm
i need to find the integral in the for loop..(means lot of times) and the function computation requires the index values(for loop variables i,j) so i need to pass these values of i and j when i m calling quad...u get my problem??
shwaip
31 May 2006, 4:41pm
f = @(x)i*j*x;
Q = quad(f,lowerbound,upperbound);
if you put both of those inside your for loops, it should do what you'd expect it to. f(x) = i*j*x; F(x) = i*j*x^2/2
jaspreet85
1 Jun 2006, 1:23pm
well,first i didnt understant the 2 functions u defined..
the function i wrote to calculate the quantitiy to be integrated
it gives me this error,''error in program at line 77,then the line where r was used in an equation ,, Reference to a cleared variable r'',,,r being the variable of integration..this comes even when im running the program for just one value of i and j , can u help with this
UOTE=shwaip]f = @(x)i*j*x;
Q = quad(f,lowerbound,upperbound);
if you put both of those inside your for loops, it should do what you'd expect it to. f(x) = i*j*x; F(x) = i*j*x^2/2[/QUOTE]
jaspreet85
1 Jun 2006, 1:35pm
also,one more thing..my function is quite huge,so it wont be possible to define it in 1 line,is it possible to have different functions having the integration variable and then combine them into one??
post your code. Enclose it in tags like this:
your code here
vBulletin® v3.8.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.