Seu SlideShare está sendo baixado. ×

# Hello- using matlab- how do I approximate this sum- I Use While loop w.docx

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio Carregando em…3
×

1 de 1 Anúncio

# Hello- using matlab- how do I approximate this sum- I Use While loop w.docx

Hello,
using matlab, how do I approximate this sum? I
Use While loop write a script in MATLAB to calculate the approximate value of With the desired of accuracy within 10^6. Prefer to the example on lecture 7 slides (using for a loop) Hint: Write the While loop based on the following Pseudocode: 1st: Define s(1) and s(2) (1 and 2rd partial sums) 2nd: Start with element n=3 of list (n is which element comes next) 3rd: Loop s(n)=s(n-1)+next term n=n+1 REPEAT LOOP WHILE |s(n-1) - s(n2)| > 10^-6 4th: Display output appropriate explanation
Solution
s=[];
s(1)= sqrt(12);
s(2)=s(1)+sqrt(-3);
n=3;
while abs(s(n-1)-s(n-2))>1e-6
s(n)=s(n-1)+sqrt(12.*(((-1).^n)./n.^2));
n=n+1;
end
s(n-1)
.

Hello,
using matlab, how do I approximate this sum? I
Use While loop write a script in MATLAB to calculate the approximate value of With the desired of accuracy within 10^6. Prefer to the example on lecture 7 slides (using for a loop) Hint: Write the While loop based on the following Pseudocode: 1st: Define s(1) and s(2) (1 and 2rd partial sums) 2nd: Start with element n=3 of list (n is which element comes next) 3rd: Loop s(n)=s(n-1)+next term n=n+1 REPEAT LOOP WHILE |s(n-1) - s(n2)| > 10^-6 4th: Display output appropriate explanation
Solution
s=[];
s(1)= sqrt(12);
s(2)=s(1)+sqrt(-3);
n=3;
while abs(s(n-1)-s(n-2))>1e-6
s(n)=s(n-1)+sqrt(12.*(((-1).^n)./n.^2));
n=n+1;
end
s(n-1)
.

Anúncio
Anúncio

### Hello- using matlab- how do I approximate this sum- I Use While loop w.docx

1. 1. Hello, using matlab, how do I approximate this sum? I Use While loop write a script in MATLAB to calculate the approximate value of With the desired of accuracy within 10^6. Prefer to the example on lecture 7 slides (using for a loop) Hint: Write the While loop based on the following Pseudocode: 1st: Define s(1) and s(2) (1 and 2rd partial sums) 2nd: Start with element n=3 of list (n is which element comes next) 3rd: Loop s(n)=s(n-1)+next term n=n+1 REPEAT LOOP WHILE |s(n-1) - s(n2)| > 10^-6 4th: Display output appropriate explanation Solution s=[]; s(1)= sqrt(12); s(2)=s(1)+sqrt(-3); n=3; while abs(s(n-1)-s(n-2))>1e-6 s(n)=s(n-1)+sqrt(12.*(((-1).^n)./n.^2)); n=n+1; end s(n-1)