Changes between Initial Version and Version 1 of cypress/Programming/ApproximatePi/MatlabExample
- Timestamp:
- 05/14/15 14:42:05 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
cypress/Programming/ApproximatePi/MatlabExample
v1 v1 1 = Ex12sq.m = 2 {{{#!matlab 3 % 4 % PI/4=sum(-1)^i/(2i+1) 5 % ex12eq.m 6 % 7 % 8 clear all; 9 % 10 tic; 11 % number of iterations 12 n=100000000; 13 % 14 x=0.0; 15 for i = 0:n 16 x = x + (-1)^i / (2 * i + 1); 17 end 18 str = sprintf('n=%d Pi=%1.16f\n',n,4.0 * x); 19 disp(str); 20 toc; 21 }}}