Info

此问题已关闭。 请重新打开它进行编辑或回答。

Problem with if and than and det

5 次查看(过去 30 天)
bondpen
bondpen 2018-4-12
关闭: bondpen 2018-4-13
So basically im trying script that determines if matrix is singular or not, by doing a det on the matrix. For example i tired doing: det([1 2;3 4]) which result in zero, but when I tired to input into the command like singularitytest([1 2;3 4]) or A=[1 2;3 4] its output is just the matrix. I am not sure which part i have gotten wrong, the If and else statements or the det? or my input command?
function result = singularitytest(A)
if det(A) == 0
c = 0;
else
c = 100;
end
  2 个评论
bondpen
bondpen 2018-4-13
Thanks! Both this and my result/variables mix up helps me.

采纳的回答

Walter Roberson
Walter Roberson 2018-4-12
You assign something to variable named c, which you then do not use.
Your function expects something to be assigned to result but you never assign to that.
  1 个评论
bondpen
bondpen 2018-4-13
Thanks! Both this and cond command helps me.

更多回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by