Algorithm/Optimization to alter initial Matrix until new condition is met?
3 views (last 30 days)
Show older comments
if B = nxn Matrix, a = 1xn vector & c = 1xn vector. Where their relationship is as follows:
B*a = c, as shown in the below code.
%example values
a1 = [0.00788506447118000; -0.00264409347536600; -0.00796087632856700; 0.00264575118338100];
B= [0.0112E8 0.0334E8 0 0
0.0337E8 1.0725E8 0 0.4687E8
0 0 0.0112E8 0.0337E8
0 0.4687E8 0.0337E8 1.0725E8];
c= [0E5; -1.33E5; 0E5; 1.33E5];
checkofC= B*a1
c is constant and will not change, however, B2*a2 = c, where 1xn vector a2 is not equal to 1xn vector a1.
Meaning this nxn matrix B2 cannot be equal to B shown above.
Assuming matrix B2 is similiar but not equal to matrix B, is there an optimization, algorithm, loop, or similiar that alters values in matrix B to create a new matrix which satisfies:
newB*a2 = c, where
a2= [0.0096; -0.0012; -0.0096; 0.0012];
c= [0E5; -1.33E5; 0E5; 1.33E5];
% newB = 4x4 matrix similiar to B above
% checkofC= newB*a2
0 Comments
Answers (1)
Ayush Aniket
on 18 Oct 2023
Edited: Ayush Aniket
on 20 Oct 2023
Hi Matthew,
As per my understanding, you want to find a new matrix ‘B’ that satisfies the matrix multiplication equation: 'newB * a2 = c', given 'c' and 'a2'.
One possible approach is to use an optimization algorithm to iteratively update the values of 'newB' until the equation is satisfied, such as the least squares method which will minimize the difference between 'newB * a2' and 'c'.
You can use ‘fminunc’ function in MATLAB to solve the optimization problem. You will need to provide the objective function, the initial guess for 'newB', and other options as per your problem criteria as follows:
% Define the objective function
objective = @(newB) sum(sum((newB * a2 - c).^2));
% Set up the optimization problem
options = optimoptions('fminunc', 'Display', 'iter');
initialGuess = B; % Use B as the initial guess for newB
% Solve the optimization problem
[newB, ~] = fminunc(objective, initialGuess, options);
% Check if newB * a2 equals c
checkofC = newB * a2;
To read more about the 'fminunc' function, you can refer to the following link:
Hope it helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!