How to find relationship between three data

5 ビュー (過去 30 日間)
Kushagra Kirtiman
Kushagra Kirtiman 2022 年 3 月 21 日
回答済み: Ayush 2023 年 11 月 14 日
I have an excel data consisting of three columns. I want to find the relationship between the the data in equation form. Can anybody explain the process for it?
  2 件のコメント
Torsten
Torsten 2022 年 3 月 21 日
編集済み: Torsten 2022 年 3 月 21 日
Either the physical background leads to a senseful relation or you must guess the functional form of the relation (mostly on the basis of a graphical representation).
Mathieu NOE
Mathieu NOE 2022 年 3 月 22 日
Can you share the data ?

サインインしてコメントする。

回答 (1 件)

Ayush
Ayush 2023 年 11 月 14 日
Hi Kushagra,
I understand that you want to find the relation between the data in the equation form for the data consisting of three columns.
You can use linear regression, which is a statistical approach to model the relation between the dependent variable and one or more independent variables.
Suppose you have “x1” and “x2” representing the first and second columns of data respectively. While the dependent third column variable is given by “y. You can use the backslash operator \” which performs a least-squares regression to obtain the coefficients for each independent variable. Thus, you will get an equation for “y” with respect to “x1” and “x2”. You can refer the code below, where I have used this operator for small sample data:
% Example data
x1 = [1; 2; 3; 4; 5]; % Independent variable 1
x2 = [4; 4; 6; 8; 10]; % Independent variable 2
y = [7; 12; 18; 24; 30]; % Dependent variable
% Create the design matrix (X) by concatenating the independent variables
X = [x1, x2];
% Perform linear regression using the backslash operator (\)
coefficients = X \ y;
% Extract the coefficients for each independent variable
b1 = coefficients(1);
b2 = coefficients(2);
% Display the equation
equation = ['y = ', num2str(b1), ' * x1 + ', num2str(b2), ' * x2'];
disp('Equation:');
Equation:
disp(equation);
y = 5 * x1 + 0.5 * x2
For more information on linear regression and usage of “\” operator, you can refer the below link:
Regards,
Ayush

カテゴリ

Help Center および File ExchangeRegression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by