How to resolve floating point zero error in the following code

for i=1:3
for j=1:3
for k=1:z
p=Q(i,j,k)*(Z(k+1)-Z(k));
q=Q(i,j,k)*(Z2(k+1)-Z2(k));
r=Q(i,j,k)*((Z(k+1))^3-(Z(k))^3);
A(i,j)= A(i,j)+p;
B(i,j)= B(i,j)+q;
D(i,j)= D(i,j)+r;
end
end
end

6 件のコメント

Walter Roberson
Walter Roberson 2018 年 12 月 5 日
What floating point zero error?
What inputs should we give when we run the code?
Manish
Manish 2018 年 12 月 5 日
編集済み: Manish 2018 年 12 月 5 日
2
1/1000
0
0
0
0
0
Walter Roberson
Walter Roberson 2018 年 12 月 5 日
Okay, so what should we be paying attention to?
Your ABD matrix is nearly singular, with rcond about 1e-9 . inv() of it is not going to be all that accurate. You should strive to avoid using inv(), preferring to use \
abd = inv(ABD); R1 = abd*[Nx;Ny;Nxy;Mx;My;Mxy];
would be better as
R1 = ABD \ [Nx;Ny;Nxy;Mx;My;Mxy];
Manish
Manish 2018 年 12 月 5 日
okay i will do that but;
in ABD matrix ABD(1,3) = ABD(2,3) = ABD(3,1) = ABD(3,2) = 0
and i ain't getting that
Walter Roberson
Walter Roberson 2018 年 12 月 5 日
Manish
Manish 2018 年 12 月 5 日
There is no way to to resolve it ?
Because i have to display the ABD matrix and
if i use A(A~= 0) = 0;
whole A matrix is resulting in zero matrix although every element is not approximately zero.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2018 年 12 月 5 日

コメント済み:

2018 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by