[Matlab Grader] How to check if the matrix has upper triangular form?

4 ビュー (過去 30 日間)
Biljana Gjeroska
Biljana Gjeroska 2020 年 12 月 21 日
コメント済み: Biljana Gjeroska 2020 年 12 月 21 日
Hi,
I want to build a test that checks if a matrix has an upper triangular form. But somehow it didn't work in Matlab Grader.
I tried to use the matlab function istriu
A = [1.6537 1.1405 1.2570;
0.0000 0.9661 0.6341;
-0.0000 0.0000 0.8816;
-0.0000 -0.0000 -0.0000;
-0.0000 0.0000 0]
isUpper = istriu(A)
but it gives me always zero back, even though the matrix is upper triangular. When I am doing it locally, it gives me the right answer.
Does someone know why is this happening and how can I solve it?

採用された回答

James Tursa
James Tursa 2020 年 12 月 21 日
編集済み: James Tursa 2020 年 12 月 21 日
This looks like a display issue. The numbers in the lower triangle are not exactly zero, they just display that way out to 4 digits. Take a look at this result:
A == 0
and you will likely see that some of those lower triangular elements are not exactly 0.
  1 件のコメント
Biljana Gjeroska
Biljana Gjeroska 2020 年 12 月 21 日
Thanks a lot. I was thinking that the numerical deviation is already taken into account. But here I need to build it manually :)

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

その他の回答 (0 件)

コミュニティ

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by