goldenratio_yourlogin

goldenratio_yourlogin - % fib_val2 - the second value of...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [fib_vector] = goldenratio_yourlogin(fib_val1,fib_val2) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Programmer(s) and Purdue Email Address(es): % 1. @purdue.edu % % Section #:ALL % % Assignment #: Homework 12 problem 5 % % Academic Integrity Statement: % % I/We have not used source code obtained from % any other unauthorized source, either modified % or unmodified. Neither have I/we provided access % to my/our code to another. The project I/we am/are % submitting is my/our own original work. % % goldenratio_yourlogin - this function calculates the golden ratio between concecutive values of the fibonacci sequence. % % INPUTS % fib_val1 - the first value of the fibonacci sequence
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % fib_val2 - the second value of the fibonacci sequence % % OUTPUTS % fib_vector - vector of fibonacci values calculated until satisfy % golden ratio %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ---- INPUT ----% % ---- CALCULATIONS ----fib_vector = [fib_val1, fib_val2, fib_val1+fib_val2]; % Initialize vector of terms in the fibonacci sequence k = 3; % Initialize index k % Loop to check if satisfy golden ratio while abs(fib_vector(k)/fib_vector(k-1)-fib_vector(k-1)/fib_vector(k-2))>0.001 fib_vector(k+1) = fib_vector(k-1) + fib_vector(k); k = k + 1; end e % ---- RESULTS ----% vector_fib = goldenratio_yourlogin(3,5) % vector_fib = 3 5 8 13 21 34 55 89...
View Full Document

This note was uploaded on 05/02/2011 for the course ENGR 132 taught by Professor Kutson during the Spring '11 term at Purdue.

Ask a homework question - tutors are online