linsolve time-consuming

3 次查看(过去 30 天)
Fikret Dogru
Fikret Dogru 2019-6-22
评论: Torsten 2019-6-27
Hello all,
Here is my code and it is running more than 2 days. Z1, Z2, A, B, D and E are known 1 X 1.000.000 vector and C and F are constant values 1X1. I am trying to estimate X and Y but the program is still working. Is there any chance to find when will it finish with these matrices? Any help will be great. Thanx all.
syms X Y
Z1=X.*A-Y.*B*C;
Z2=X.*D-Y.*E*F;
[A,B]=equationsToMatrix([Z1,Z2], [X,Y]);
X = linsolve(A,B);

采纳的回答

Stephan
Stephan 2019-6-23
Get rid of symbolic calculation - this makes code very slow and solve numeric:
clear X Y
% This works if your values are of size 1 x 1.000.000
X = linsolve([A', (-B.*C)'; D.' (-E.*F)'],[Z1'; Z2'])
  5 个评论
Stephan
Stephan 2019-6-27
编辑:Stephan 2019-6-27
You should thank Torsten - but here is an explaination of what he did:
syms X Y A B C D E F Z1 Z2
eq(1) = Z1==X.*A-Y.*B*C;
eq(2) = Z2==X.*D-Y.*E*F;
sol = solve(eq,[X,Y]);
sol.X
sol.Y
Torsten
Torsten 2019-6-27
@ Fikret Dogru:
The method is called "Cramer's rule".

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by