MATLAB: Approximating pi with taylor series expansion to the 10,000th term This was my code: I=0 while (I<10000) I=((-1)^I)/(2*I+1) end x=4*I so when I do that the answer shows as x = NaN + NaNi Best Answer charlotte, you are almost there: l = 1; for ii = 1:10000 l = l + ((-1)^ii)/(2*ii + 1); end x = 4*l;If the number of iterations (series terms) is know, use a for-loopii is the loop index, l is the approximation to pi/4 Related SolutionsMATLAB: EMERGENCY Cannot plot “10,000*exp(-10000*t);” Because you used a comma to define the 10000, and MATLAB sees that comma as a statement separator. MATLAB interprets this lineImpulse = 10,000*exp(-10000*t);as two separate statementsImpulse = 10000*exp(-10000*t);Get rid of the comma.Impulse = 10000*exp(-10000*t); MATLAB: Using Linear congruential to generate 10,000 uniform random variables You need an intial value for X(1); and you need to set for n=2:10000 X(n+1)=mod((a*X(n)+c), m);end Related QuestionDouble loop formation questionSolving questions related to taylor series expansion
Best Answer