optimization for minimum difference between 2 graphs

1 visualización (últimos 30 días)
Kinda Chakas
Kinda Chakas el 8 de Ag. de 2020
Editada: ag el 7 de Feb. de 2025
I have two graphs: graph 1 and grph 2
I want to find a,b such that: normalized graph1=graph 1 * a+b.
a and b should be chosen to give the minimum difference between normalized graph 1 and graph 2.
Thank you in advance for your help.

Respuestas (1)

ag
ag el 7 de Feb. de 2025
Editada: ag el 7 de Feb. de 2025
Hi Kinda,
To find the optimal values of ( a ) and ( b ) such that the normalized version of graph 1 (i.e., graph1 * a + b) minimizes the difference with graph 2, you can use a least squares approach. This is essentially a linear regression problem where you aim to fit graph1 to graph2.
Below is a basic illustration of how you can achieve it:
graph1 = [1 2 0; 0 4 3]; % Your graph 1 data
graph2 = [8;18]; % Your graph 2 data
% Set up the design matrix for linear regression
X = [graph1, ones(size(graph1))];
% Solve the linear regression problem using the backslash operator
coefficients = X \ graph2;
% Extract the coefficients a and b
a = coefficients(1);
b = coefficients(2);
% Calculate the normalized graph1
normalized_graph1 = graph1 * a + b;
Please ensure to modify the code as per your requirements.
For more details, please refer to the following MathWorks documentation:
Hope this helps!

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by