optimization for minimum difference between 2 graphs

5 ビュー (過去 30 日間)
Kinda Chakas
Kinda Chakas 2020 年 8 月 8 日
編集済み: ag 2025 年 2 月 7 日 5:06
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 日 5:05
編集済み: ag 2025 年 2 月 7 日 5:06
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 Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by