필터 지우기
필터 지우기

Function or code in Matlab that can determine the linear equation given input data on two variables

조회 수: 5 (최근 30일)
Hello Matlab wizards, I am having a bit of challenge running an optimization problem here. I was wondering if there is a way; command, code or some sort of function in Matlab that can determine the linear relationship between two sets of variables. something like Y=a+Xb; Y, and X are the variables, a is the intercept and b is the slope. I have data set for Y and X and I can draw the plot(Supply curve in my case to be very specific). I will elaborate a little bit more in boring Economics terms; suppose a supply function f that represents a relationship between Price and Q. So I am trying to determine what the equation for my plots/lines could be in form of Q=a-P*b (in this case Q is Y and P is X). Can this be done in Matlab or am I way out of luck here? Thank you so much in advance

답변 (1개)

Star Strider
Star Strider 2016년 9월 28일
See the documentation for polyfit and polyval and mldivide.
  댓글 수: 2
Amine Ben Ayara
Amine Ben Ayara 2016년 9월 29일
Hello Star, Thank you so much for your help, again. So I found this information : https://www.mathworks.com/help/matlab/data_analysis/programmatic-fitting.html Based on that, it seems like I would need to know the equation before hand, right? I only have the values of Y, and X and I can plot the line using plot(X,Y), So Do I just assume the function is a second-degree polynomial. The curve is concave with a postive slope.
Star Strider
Star Strider 2016년 9월 30일
My pleasure.
You can fit a second-degree polynomial with polyfit.
Sorry for the delay. Life and software updates intrude.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by