my program throws multiple exceptions but I want to code it like that when it receives first exception should not move furthur and quit by returning a value

2 次查看(过去 30 天)
input to svd is
Inf NaN NaN
NaN NaN NaN
NaN NaN NaN
Error using svd
Input to SVD must not contain NaN or Inf.
CODE IS:::
s = svd(A);
if any(s == 0) % Handle singular matrix
c = Inf(class(A));
else
c = max(s)./min(s);
if isempty(c)
c = zeros(class(A));
end
end

回答(1 个)

Walter Roberson
Walter Roberson 2018-9-27
https://www.mathworks.com/matlabcentral/answers/420813-a-test-to-exclude-inf-and-nans-from-pinv-doesn-t-work#answer_338496

类别

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