optimization for minimum difference between 2 graphs

조회 수: 1 (최근 30일)
Kinda Chakas
Kinda Chakas 2020년 8월 8일
편집: ag 2025년 2월 7일
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.

답변 (1개)

ag
ag 2025년 2월 7일
편집: ag 2025년 2월 7일
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!

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by