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

How do you create functions in Matlab for linear, power, and exponential trend t

ID: 1846093 • Letter: H

Question

How do you create functions in Matlab for linear, power, and exponential trend types which are able to do the following?

- Pass in the data to be used on the abscissa and then the data to be used on the ordinate in data vector form without using the "input" function

- Perform the appropriate polyfit analysis to find the "m" and "b" parameters

- Allow the user to input the desired axis labels and title

- Allow the user to input the desired variable names for "x" and "y"

- Plot the experimental data, following all the proper plot rules with axis limits that reflect the data range.

- On the same plot, plot the appropriate trenlind following all the proper plot rules with flexible axis limits and the appropriatae equation included to the right of the final data point

- Pass the "m" and "b" parameters back out of the function

Explanation / Answer

function [m b]=my_fun(abscissa,ordinate)

x=abscissa;

y=ordinate;

p=polyfit(x,y,1); %for linear

m=p(2);

b=p(1);

label1=input('enter the x-label');

label2=input('enter the y-label ');

title1=input('enter the title ');

plot(x,y)

xlabel(label)

ylabel(label2)

hold on

y1=m*x+b;

plot(x,y1,'--')

xlabel(label)

ylabel(label2)

title(title)


hold off

grid on


end

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