Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions