- , , , .
I use the following code to be able to quickly check the nnz () variable, although you can change the code in a nested try-catch to whatever you need.
Finally, I created a shortcut with this code in the upper right corner of Matlab, which I quickly access by pressing Alt-1.
try
activeEditor = matlab.desktop.editor.getActive;
currentSelection = activeEditor.SelectedText;
try
eval(sprintf('val = nnz(%s);',currentSelection))
disp(sprintf('>> nnz(%s) = %s',currentSelection,num2str(val)))
catch ex
disp(ex.message)
end
catch ex
disp(ex.message)
end
source
share