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

Hi, I need a MATLAB code that will give me the values at the intercept of each s

ID: 3160751 • Letter: H

Question

Hi,

I need a MATLAB code that will give me the values at the intercept of each slope with the straight horizontal line:

OD_ave = plot([1 600],[0.00835 0.00835],'k');

The slopes are:

FODD1 = fit( Time(3:11)' , ODD1_ave(3:11)', 'exp1');

plot(FODD1, 'g');

FODE1 = fit( Time(3:11)' , ODE1_ave(3:11)', 'exp1');

plot(FODE1, 'k');

FODF1 = fit( Time(1:10)' , ODF1_ave(1:10)', 'exp1');

plot(FODF1, 'b');

FODG1 = fit( Time(1:10)' , ODG1_ave(1:10)', 'exp1');

plot(FODG1, 'm');

FODH1 = fit( Time(2:10)' , ODH1_ave(2:10)', 'exp1');

plot(FODH1, 'r');

Also,I would it would be very nice if I could have a circle on the intercept as well.

Thanks!!

a 10 102E 10 o er

Explanation / Answer

x = linspace(-10, 10, 20); % Make 20 samples along the x axis % Linear relation, with noise slope = 1.5; intercept = -1; noiseAmplitude = 15; y = slope .* x + intercept + noiseAmplitude * rand(1, length(x)); % Plot the training set of data. subplot(2, 1, 1); plot(x, y, 'ro', 'MarkerSize', 8, 'LineWidth', 2); grid on; xlabel('X', 'FontSize', fontSize); ylabel('Y', 'FontSize', fontSize); title('Linear Fit', 'FontSize', fontSize); % Enlarge figure to full screen. set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]); % Give a name to the title bar. set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off') % Do the regression with polyfit linearCoefficients = polyfit(x, y, 1) % The x coefficient, slope, is coefficients(1). % The constant, the intercept, is coefficients(2). % Make fit. It does NOT need to have the same % number of elements as your training set, % or the same range, though it could if you want. % Make 300 fitted samples going from -15 to +20. xFit = linspace(-15, 20, 500); % Get the estimated values with polyval() yFit = polyval(linearCoefficients, xFit); % Plot the fit hold on; plot(xFit, yFit, 'b', 'LineWidth', 2); legend('Training Set', 'Fit', 'Location', 'Northwest'); %============= CUBIC FIT =================================== x = linspace(-10, 10, 20); % Make 20 samples along the x axis % Cubic relation, with noise c1 = 1; c2 = 2; c3 = -10; c4 = 4; noiseAmplitude = 500; y = c1 .* x .^3 + c2 .* x .^2 + c3 .* x + c4 + noiseAmplitude * rand(1, length(x)); % Plot the training set of data. subplot(2, 1, 2); plot(x, y, 'ro', 'MarkerSize', 8, 'LineWidth', 2); grid on; xlabel('X', 'FontSize', fontSize); ylabel('Y', 'FontSize', fontSize); title('Cubic Fit', 'FontSize', fontSize); % Do the regression with polyfit cubicCefficients = polyfit(x, y, 3) % The x coefficient, slope, is coefficients(1). % The constant, the intercept, is coefficients(2). % Make fit. It does NOT need to have the same % number of elements as your training set, % or the same range, though it could if you want. % Make 300 fitted samples going from -13 to +12. xFit = linspace(-13, 12, 500); % Get the estimated values with polyval() yFit = polyval(cubicCefficients, xFit); % Plot the fit hold on; plot(xFit, yFit, 'b', 'LineWidth', 2); grid on; legend('Training Set', 'Fit', 'Location', 'Northwest');

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