Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ok everything works fine except I want to put my input as a vector not just a si

ID: 3529592 • Letter: O

Question

ok everything works fine except I want to put my input as a vector not just a single value like n=10 n=20 and n=30 [ 10 20 30] to where when i enter this I get three answers. I think i need to use array addressing but im not sure. im so close please help. disp('problem 2') n=input('Enter the number of terms as a vector:'); l=0; s=pi; for k=0:1:n l=l+sqrt(12)*(((-3).^(-k))./(2*k+1)); a=l; j=abs(s-a); end fprintf(' the diffrence between the series and pi is:%i ',j) fprintf(' the diffrence: %g ',j)

Explanation / Answer

%I'm not sure exactly what your program want to do, so you may have to change loop


disp('problem 2')

n=input('Enter the number of terms as a vector:','s'); %read in a string


N=strread(n,'%s','delimiter',' '); %strip the string into column array by space delimiter

N=str2double(N); %change from string to double


l=0;

s=pi;