Register to reply 
Need help creating a recursive script in matlab that can do this: 
Share this thread: 
#1
Jul3010, 02:35 AM

P: 58

Need help creating a recursive script in matlab that can do this:
S = 1^2 + 2 ^2 + 3^2 + ... + n^2 : P Thanks. 


#2
Jul3010, 05:54 AM

Sci Advisor
PF Gold
P: 477

This should do it:
S = sum((1:n).^2); (1:n) creates an array of integers from 1 to n the .^2 squares each element and the sum() function does what it says. 


Register to reply 
Related Discussions  
Recursion in C  Programming & Computer Science  12  
Function is F(n) = n(n+1)  General Math  4  
Recursive function in a physics equation  General Physics  6  
Formulating an equation which utilizes a recursive function  General Math  0  
What is the largest number of pieces you can get by cutting a pizza  Introductory Physics Homework  1 