Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7. (Matlab) Write a MATLAB user-defined uite a MATLAB user-defined function that

ID: 3703370 • Letter: 7

Question

7. (Matlab) Write a MATLAB user-defined uite a MATLAB user-defined function that determines the best fit of an exponential function of the form y = bemx to a given set of data points. Name the function [b m] =ExpoFit(x,y), where the input arguments x and y are vectors with the coordinates of the data points, and the output arguments b and m are the values of the coefficients. The function ExpoFit should use the approach that is described in the lecture note for determining the value of the coefficients. Use the function to solve Problem #2.

Explanation / Answer

clc; % Clear the command window. workspace; % Make sure the workspace panel is showing. format long g; format compact; fontSize = 20; %taking sample vectors for x and y x = [0.5 2.4 3.2 4.9 6.5 7.8]'; y = [0.8 9.3 37.9 68.2 155 198]'; plot(x,y,'+r'), hold on p = polyfit(log(x),log(y),1); m = p(1); b = exp(p(2)); ezplot(@(x) b*x.^m,[x(1) x(end)]) f = fit(x,y,'b*x^m'); plot(f,'k')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote