How to write a conditional statement for tridiagonal matrix.

1 次查看(过去 30 天)
Hi! I have tridiagonal matrix function where I need to have a conditional statement if a, b, and c contain any nonzero values. If they contain a 0 then I must write an error the the program as the diagonals have to be nonzero values. Attached are the main program with comments and the function program

采纳的回答

Matt J
Matt J 2021-4-1
编辑:Matt J 2021-4-1
a = [3 4 0 8];
validateattributes(a,"numeric", "nonzero")
Expected input to be nonzero.
  2 个评论
Manny
Manny 2021-4-1
Thank you! How would I be able to incorporate validateattributes as a conditional statement?
Matt J
Matt J 2021-4-1
You don't need to. As you can see from the output above, it does the whole task of checking whether a has the right properties from start to finish, including generating the error message.

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by