Get calculated output arguments when an error is thrown

1 回表示 (過去 30 日間)
Yoad Pilosof
Yoad Pilosof 2023 年 2 月 21 日
回答済み: Walter Roberson 2023 年 2 月 21 日
Say I have the following function, that calculates the transpose and inverse of a matrix:
function [At, Ai] = TransposeAndInverse(A)
At = A.';
Ai = inv(A);
end
and I call it with the following argument:
A = [1,2,3;4,5,6];
[At, Ai] = TransposeAndInverse(A);
I get an error, since A is not invertible (as expected). However, inside the function, At was calculated successfully.
My question is - can I somehow extract the output arguments that were calculated before the error was thrown using a try catch statement? And if so, how?
Thanks

採用された回答

Walter Roberson
Walter Roberson 2023 年 2 月 21 日
No, the function would have to be designed to use try/catch itself. Once an error is thrown and the function has returned all of its internal variables are gone.

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by