Question

Write a MATLAB function that accepts any sets of point and fits a straight line using the least square method. Test your func

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc%clears screen
clear all%clears history
close all%closes all files
format long
x=[-1.3,-0.1,0.2,1.3];
y=[0.103,1.099,0.808,1.897];
[a,b]=fitLine(x,y)


function [a,b]=fitLine(x,y)
A=[x(:) ones(numel(x),1)];
B=y(:);
C=A\B;
a=C(1);
b=C(2);
end

- O X Pradeep EDITOR PUBLISH VIEW do E C . Search Documentation Insert fx Comment % 92% Indent 1 - EDIT Run Section Advance B

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB function that accepts any sets of point and fits a straight line using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Below are four bivariate data sets and the scatter plot for each. (Note that each scatter...

    Below are four bivariate data sets and the scatter plot for each. (Note that each scatter plot is displayed on the same scale.) Each data set is made up of sample values drawn from a population. x   y 1.0   4.1 2.0   6.1 3.0   7.0 4.0   4.0 5.0   5.2 6.0   8.1 7.0   5.5 8.0   6.9 9.0   9.0 10.0   7.3 x1234567891011y12345678910110 Figure 1    u   v 1.0   8.1 2.0   7.4 3.0   8.1 4.0   6.1 5.0   7.4 6.0   4.5 7.0   4.6 8.0   3.4...

  • Below are four bivariate data sets and the scatter plot for each. (Note that each scatter...

    Below are four bivariate data sets and the scatter plot for each. (Note that each scatter plot is displayed on the same scale.) Each data set is made up of sample values drawn from a population. y 1.0 7.4 2.0 9.0 3.0 7.0 11 10- 11 102 9 8+ 7+ 8+ 71 61 5 5 41 4.0 5.4 5.0 7.5 6.05.2 7.0 4.5 8.0 7.1 9.0 5.5 10.0 3.9 V 1.0 8.0 2.0 6.9 3.07.3 4.0 6.1 5.0 7.4 6.0...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • Using separate files, write the definition for a class called Point and a class called Circle. Th...

    Using separate files, write the definition for a class called Point and a class called Circle. The class point has the data members x (double) and y (double) for the x and y coordinates. The class has the following member functions: a) void set_x(double) to set the x data member b) void set_y(double) to set the y data member c) double get_x() to return the the x data member d) double get_y() to return the the y data member e)...

  • solve all questions simply by using matlab. write all step here please 1Normal 1 No Spac Heading1 Heading 2 DISCUSSION Solve all tasks given below: 1. Consider function f(x) 3.5-0.5x cos(6x) for...

    solve all questions simply by using matlab. write all step here please 1Normal 1 No Spac Heading1 Heading 2 DISCUSSION Solve all tasks given below: 1. Consider function f(x) 3.5-0.5x cos(6x) for the value of x between -2.0 until 4.0. Draw the plot in dash line and in red colour, Label the title and all axes. 2. Consider the following functions for 0sxS pi: x() 10e0.St sin(3t +2) y(t) 7e-04t cos(5t - 3) (a) Draw both graphs on the same...

  • answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for...

    answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for a user defined function that is named Feynman and has input variables q and e, and outputs L and M. (Comment out of this line). 2. Using zeros, ones, and eye commands write the one line syntax to create the following matrix: 00000 01100 01010 01001 3. Write the syntax for the user defined function that calculates the surface area and volume of a...

  • (I) Let's start with very simple data table 1.0 2.0 3.0 4.0 5.0 6.0 -1 ±...

    (I) Let's start with very simple data table 1.0 2.0 3.0 4.0 5.0 6.0 -1 ± 1.8 4±2.0 9+ 1.0 14 + 0.8 19 s 0.8 24 + 1.2 2% 1.8 34 ± 2.0 7.0 8.0 9.0 1. Plot a graph of y vs. X on a piece of graph paper 2. Is it a straight line? Draw the best-fit line. 3. Compute the slope and y-intercept for this line. Write the equation for y in terms of x using...

  • f. The amplitude of a cosine can be observed at the origin (t=0) when there is no phase shift. Find a simplified solutio...

    f. The amplitude of a cosine can be observed at the origin (t=0) when there is no phase shift. Find a simplified solution for the convolution integral below for t=0. +∞ output(t) = h(t)∗ s(t) = −∞ 3 rect(3x) cos(2π f0 (t − x)) dx Hint: Set t=0, sketch the situation to help set up the integral and remember the properties of odd and even functions to simply the calculation. g. The above result gives a general expression for the...

  • f. The amplitude of a cosine can be observed at the origin (t=0) when there is...

    f. The amplitude of a cosine can be observed at the origin (t=0) when there is no phase shift. Find a simplified solution for the convolution integral below for t=0. +∞ output(t) = h(t)∗ s(t) = −∞ 3 rect(3x) cos(2π f0 (t − x)) dx Hint: Set t=0, sketch the situation to help set up the integral and remember the properties of odd and even functions to simply the calculation. g. The above result gives a general expression for the...

  • help please, i dont know how to do it Charging A 1000uF capacitor was charged using...

    help please, i dont know how to do it Charging A 1000uF capacitor was charged using a battery of Vo = 10V via two resistors Ry = 47kN and R2 = 27k1. The simulation was run for a total time duration of 300s. Fig 1(a) shows the charging circuit used for the simulation, Fig 1() shows the Voltage vs. time (V-t) response of the circuit charging via Rę = 47kN and Fig 1(c) shows the (V-1) response of the circuit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT