Minimizing an equation to 0

조회 수: 10 (최근 30일)
AAS
AAS 2022년 9월 11일
편집: Bruno Luong 2022년 9월 11일
I have an equation where I am trying to reduce the RMS to 0 i.e RMS(A-(B+C)<=0. A,B and C are known but the RMS is not equal to 0 . Now, I want to modify this equation such that RMS(A-(k1*B+k2*C)<=0. I want to find k1 and k2 to make the RMS as close to 0. How could I do this?
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 9월 11일
are A, B, C matrices? Are k1 and k2 scalar?
AAS
AAS 2022년 9월 11일
yes, A,B and C are matrices and k1 and k2 are scalars.

댓글을 달려면 로그인하십시오.

답변 (3개)

Alan Stevens
Alan Stevens 2022년 9월 11일
Try fminsearch
  댓글 수: 1
AAS
AAS 2022년 9월 11일
I tried to implement it this way.. however, it did not produce good resuts, barely did any minimization. Am I implementing it right?
f = @(k) rms(C-(k(1)*A+k(2)*B));;
k0=[1 1];
[xmin] = fminsearch(f,k0,options);
f(xmin);

댓글을 달려면 로그인하십시오.


Torsten
Torsten 2022년 9월 11일
편집: Torsten 2022년 9월 11일
A = [4 3; 6 2; 7 -3];
B = [1 -3; 2 2; 5 -pi];
C = [12 -0.5; 7 -3; 0 1];
fun = @(p)reshape(A-(p(1)*B+p(2)*C),[],1);
sol = lsqnonlin(fun,[1 1])
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
sol = 1×2
0.9421 0.3061
error = rms(fun(sol))
error = 2.7826

Bruno Luong
Bruno Luong 2022년 9월 11일
편집: Bruno Luong 2022년 9월 11일
This minimize the frobenius norm, or l2 norm of the vectorized residual matrix (divided by sqrt(numel(A)) you'll get the rms)
k=[B(:),C(:)]\A(:);
k1=k(1);
k2=k(2);

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by