Register to reply 
Interpreting Matlab function simp 
Share this thread: 
#1
Feb2713, 06:15 AM

P: 34

Hello, guys
Hey guys, Got stuck with function integration using Simpson's rule and need your help. Please first refer to picture attached for full idea of my question: The Matlab command related to it is: for i=1:nr u1d(i)=4.0*pi*r(i)^2*u(it,i) end I1=simp(0.0,r0,nr,u1d)/(4.0/3.0*pi*r0^3) I1 is nr=21 r0=1.0; Does it mean that I1 is integrated 21 times between boundaries 0 and r0? 


#2
Feb2713, 08:12 AM

P: 535

Can you post more information? The code you posted references variables that you never define. Make it so that your code block can be copy/pasted into matlab.



#3
Feb2713, 08:27 AM

P: 34

Yes. Sure
I have attached all commands with order from Pic.1 to Pic.3 


#4
Feb2713, 08:46 AM

P: 535

Interpreting Matlab function simp
simp() is not a matlab function, so the information about the input arguments is not available in the documentation. I suggest looking at the function file for simp() to find this info.



#5
Feb2713, 09:04 AM

P: 535

EDIT: I found information about this function in the MATLAB file exchange.
f=function, a=initial value, b=end value, h=interval size 


#6
Feb2713, 04:27 PM

P: 34

I have found it as separate m.file. Here are the commands:
function uint=simp(xl,xu,n,u) h=(xuxl)/(n1); uint(1)=u(1)u(n); for i=3:2:n uint(1)=uint(1)+4.0*u(i1)+2.0*u(i); end uint=h/3.0*uint; But why here different variables are used such as xl and xu? It seems to me that we use r in integration? 


#7
Feb2713, 09:55 PM

P: 535

At a glance it looks like
xl = beginning of interval xu = end of interval n = number of slices u = function So in your case of



#8
Feb2813, 03:50 AM

P: 34




Register to reply 
Related Discussions  
Ramp Function in MATLAB? also window adjustments (MATLAB Help)  Introductory Physics Homework  2  
Simple structure function  interpreting answer [Probability & Reliability Theory]  Calculus & Beyond Homework  0  
Interpreting a function based on it's equation.  General Math  28  
Simp,e Harmonic Motion with Damping  Classical Physics  4  
Simp Simultaneous Equation  Precalculus Mathematics Homework  7 