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 CenterFile Exchange에서 Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by