some question about optimization

2 visualizaciones (últimos 30 días)
liu lin
liu lin el 9 de Abr. de 2018
Editada: Stephan el 28 de Abr. de 2018
I have a function: A=W*S, A is a matrix of 4*1000, and S is a matrix of 2*1000, then I want to get a optimized matrix W of 4*2 to make the equation as good as possible, so I want to know how to solve this problem, can I use the optimization toolbox

Respuestas (1)

Stephan
Stephan el 28 de Abr. de 2018
Editada: Stephan el 28 de Abr. de 2018
Hi,
try this command:
W = A/S
Here is an example for small data:
>> A = [1 2; 3 5; 3 8; 2 7; 8 11]
A =
1 2
3 5
3 8
2 7
8 11
>> S = [1 5; 3 6; -4 9]
S =
1 5
3 6
-4 9
>> W = A/S
W =
0 0.3333 0.0000
0 0.9216 -0.0588
0 1.1569 0.1176
0 0.9020 0.1765
0 2.2745 -0.2941
>> x = int8(W*S)
x =
5×2 int8 matrix
1 2
3 5
3 8
2 7
8 11
>> Test = A == x
Test =
5×2 logical array
1 1
1 1
1 1
1 1
1 1
That's what you wanted to do?
The result of this procedure will depend strongly on how well the matrices A and S correlate and how large the measurement errors / noise in the data is i think. Therefore, I recommend checking the result with the test A = B with B = W * S as shown. The fraction of zeros in the logical matrix resulting from the review is an indicator of the goodness of this approach, I think. You should be aware that there are rounding errors and include them in the evaluation.
For bigger examples with added errors which disturb the linear dependencies it still works good i think:
S = (randi(25, 2, 1000));
A = ones(4, 1000);
A(1,:) = sin(S(1,:));
A(2,:) = 2 * S(2,:);
A(3,:) = 0.5 * S(2,:) + log(S(2,:));
A(4,:) = -5 * S(1,:);
W = vpa(A/S);
A = int8(A);
x = sum(sum(int8(W*S) == A)) / 4000
same = int8(W*S) == A;
Lines 1 to 6 just construct a problem of your dimensions with built in non linearity to simulate bad data / noise for testing.
x is the ratio of correct calculated elements by the operation A/S and reached about 0.748...0.759 for this example.
I hope this works for your purpose.
best regards
Stephan

Categorías

Más información sobre Optimization Toolbox 快速入门 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!