How to find relationship between three data

6 vues (au cours des 30 derniers jours)
Kushagra Kirtiman
Kushagra Kirtiman le 21 Mar 2022
Réponse apportée : Ayush le 14 Nov 2023
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 commentaires
Torsten
Torsten le 21 Mar 2022
Modifié(e) : Torsten le 21 Mar 2022
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 le 22 Mar 2022
Can you share the data ?

Connectez-vous pour commenter.

Réponses (1)

Ayush
Ayush le 14 Nov 2023
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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by