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 日

2 投票

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 件のコメント

Fikret Dogru
Fikret Dogru 2019 年 6 月 27 日
Thanks for your help but I got an error. "Requested 2317620x1158810 (10004.9GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information." Do you have any idea to solve this?
Torsten
Torsten 2019 年 6 月 27 日
編集済み: Torsten 2019 年 6 月 27 日
Y = (Z1.*D - Z2.*A) ./ (A.*E*F - B.*D*C);
X = (Z1.*E*F - Z2.*B*C) ./ (A.*E*F - B.*D*C);
if the denominator is different from zero.
Fikret Dogru
Fikret Dogru 2019 年 6 月 27 日
Thanks Stephan,
it helped but which method is this? It is the first time I have seen solving problem like that.
Fikret
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 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2019 年 6 月 22 日

コメント済み:

2019 年 6 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by