How to solve y/x if y = x + a in matlab ?

1 view (last 30 days)
Cagdas
Cagdas on 29 Sep 2013
Commented: Image Analyst on 29 Sep 2013
Hello all,
How can you derive y/x in terms of 'a' if y = x + a in matlab? Which commands are needed for that?
Thank you.
  3 Comments
Cagdas
Cagdas on 29 Sep 2013
yes im sorry i edited it.
Image Analyst
Image Analyst on 29 Sep 2013
Yes, but it's still not a well explained question. If my answer below doesn't explain it then please see http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer and try to explain it better. Otherwise we'll just say y/x = (x+a)/x, which I don't think is all that useful or interesting.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 29 Sep 2013
y/x is used for linear regressions. To do a linear regression, you need to make a "tall" matrix with all the x and y values listed:
y1 = m * x1 + a
y2 = m * x2 + a
y3 = m * x3 + a
y4 = m * x4 + a
y5 = m * x5 + a
y6 = m * x6 + a
etc. This gives y = x * coeffs where
y = [y1;y2;y3;y4;y5;y6]
x = [
x1, 1;
x2, 1;
x3, 1;
x4, 1;
x5, 1;
x6, 1];
then coeffs = y/x and m = coeffs(1) and a = coeffs(2). Standard least squares formula but in a more compact MATLAB-ish way.

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!