Question: Please help with this matlab function. I'm not sure what I am doing wrong. function [n,piVal,error]=findPiValue(targetError) n=0; piVal=0; error=targetError+1; prevVal=0; k=0; while (error>targetError) k=k+1; prevVal=piVal;

Please help with this matlab function. I'm not sure what I am doing wrong.

function [n,piVal,error]=findPiValue(targetError) n=0; piVal=0; error=targetError+1; prevVal=0; k=0; while (error>targetError) k=k+1; prevVal=piVal; piVal=piVal+((-1).^(k+1).*4)./(2.*k-1); error=abs((piVal-prevVal)./piVal).*100; %need an equation that solves for n end end

Command window Error in findPiValue (line 4) error=targetError+1; >> findPiValue Not enough input arguments.

Error in findPiValue (line 4) error=2*targetError; findPiValue Not enough input arguments.

Error in findPiValue (line 4) error=2*targetError; >> findPiValue Not enough input arguments.

Error in findPiValue (line 4) error=2*targetError;

Here is the original question for reference:

Write a MATLAB function [n,piVal,err]=findPiValue(targetError) that determines the minimum number of terms of the series n required to achieve an absolute value of the true percentage relative error (err) that is less than or equal to targetError

. Here piVal is value of determined by summing the first n terms of the series. Submit a printout of the function. Hint: Think of using a while loop.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!