MATLAB: How to code While Loops for Convergence (pi approximation)

Опубликовано: 09 Октябрь 2024
на канале: Engineering with Dr. Kelsey Joy
4,290
46

How to code while loops in MATLAB and running totals (recursion) for the purpose of creating a solution with convergence. The develop a code to find the approximation of pi within a user-defined tolerance (input) based on the Leibniz formula for pi.

Here is the code that I wrote in the video along with additional notes: https://www.mathworks.com/matlabcentr...

How to Create Programs in MATLAB tutorial playlist:    • How to Create Programs in MATLAB (tut...  

#MATLAB #learntocode #while #whileloop #whileloops #engineeringstudent #engineeringstudents #engineering #engineer #coding #code #programming #program

Chapters:
00:00 Introducing the problem
02:37 Flowchart of the solution (underlying mathematical model)
03:13 Start of code (ensure equation is coded correctly)
04:04 Coding second iteration (running totals)
05:17 Coding the while loop (what code needs to repeat)
05:46 Determining/coding the condition on the while loop
07:48 Coding the update within the while loop (control variable: accuracy)
08:30 Running the code to test the while loop
09:08 Summary