Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab help. What would I put in blanks in line 7 time()=n; line 41 and 43. I'm trying to extrapolate to get fibnum(50) by plotting

Matlab help. What would I put in blanks in line 7 time()=n; line 41 and 43. I'm trying to extrapolate to get fibnum(50) by plotting the time elapsed with semilogy(time) and finding the slope, to find the equation of the line in semi-log space.

image text in transcribed

%% SCRIPT TO ESTIMATE THE EXECUTION TIME TO FIBNUM(N) 2 time-zeros (1,35); 3 n-length(i); 4 for i-15:n tic; f fibnum(1); 7time(X)-n; 8 end 1e figure (1) 11 plot(time) 12 xlabel ( 'Number Fibonacci Terms); 13 ylabel( Execution time (sec) 4 title('Execution time in linear space'); 161 %% 17 figure(2) 18 semilogy (time) 19 xlabel('time') 20 ylabel('semilogy (time)' 21 title(Execution time in semi-log space 23 %%THE SLOPE 24 figure (3) 25 slope-vector = diff(log(time)); 26 plot(slope_vector) 27 xlabel( Number Fibonacci Terms); 28 ylabel( 'Approximate slope); 29 title( 'Approximate slope of log(time) vs Number Fibonacci Terms') 30 31 32 %% TAKE THE LAST VALUE OF slope-vector TO BE THE SLOPE 33 slope slope-vector(end); 34 fprintf( 'The slope is %f" "); 35 36%%THE Y INTERCEPT 37 % At n 35 38 intcpt--slope 35+time (35); 39 40 %% EXTRAPOLATING TO n = 50 41 log time 50 = 50 + intcpt; 42 43 time-at-se = ^se; 44 tprintf( 'It would take approximately %g seconds to ecvaluate fibnum(50). ',time at 50

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Be straight in the back without blowing out the chest

Answered: 1 week ago

Question

Presentations Approaches to Conveying Information

Answered: 1 week ago