Changes between Initial Version and Version 1 of cypress/Programming/ApproximatePi/MatlabExample


Ignore:
Timestamp:
May 14, 2015 2:42:05 PM (7 years ago)
Author:
cmaggio
Comment:

migrated content from ccs wiki

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%
     8clear all;
     9%
     10tic;
     11% number of iterations
     12n=100000000;
     13%
     14x=0.0;
     15for i = 0:n
     16    x = x + (-1)^i / (2 * i + 1);
     17end
     18str = sprintf('n=%d Pi=%1.16f\n',n,4.0 * x);
     19disp(str);
     20toc;
     21}}}