ESG 111 Lecture Notes - Lecture 6: Leibniz Formula For Determinants, Matlab
Document Summary
% call a function to display a menu and get a choice choice = fn_pi_menu; % choice 4 is to exit the program if choice==4 return; end while choice ~= 4 switch choice case 1. % print result from machin"s formula fn_pi_machin case 2. % allowing user to specify # of terms fn_pi_leibnizn case 3. % until a good approximation is found fn_pi_approx end. % display menu again and get user"s choice choice = fn_pi_menu; end fn_pi_menu function choice = fn_pi_menu. % print the menu of options and error-check. % until the user pushes one of the buttons. % returns integer of user"s choice, 1-4 choice = menu("choose a pi option", "machin formula", % if the user closes the menu box rather than. % pushing one of the buttons, choice will be 0 while choice == 0 disp("error - please choose one of the options. ") choice = menu("choose a pi option", "machin formula",