format of an output of a function
1 回表示 (過去 30 日間)
古いコメントを表示
Suppose A is 100*1 categorical and B is 100*1 categorical . As I run ismember(A,B), output is like
ans = 100*1 logical array
1
1
1
1
1
1
1
.
.
.
Thus I cannot see the output unless I auto-scroll that is not convenient. Is there any other way to display the output? For example, is it possible to have an output that does not require auto-scroll in the horizontal format such as
ans = 1 1 1 1 1 1 1 1 1 (100 of 1s)
0 件のコメント
採用された回答
Walter Roberson
2021 年 1 月 24 日
ismember(A,B).'
you would have received a row vector if A was a row vector
ismember(A(:).',B)
3 件のコメント
Walter Roberson
2021 年 1 月 24 日
A = randi(3, 100,1);
B = [1 3];
SHOW("ismember(A,B)")
function SHOW(COMMAND)
try
output = evalc("evalin('caller', '" + COMMAND + "')");
catch ME
output = getReport(ME);
end
output = regexp(output, '\n', 'split');
fig = uifigure('name', 'show output');
figpos = fig.Position;
tpos = [10, 10, figpos(3)-20, figpos(4)-20];
tarea = uitextarea(fig, 'editable', 'off', 'Position', tpos, 'Value', output);
end
Unfortunately, I cannot demonstrate the output as the new Run facility here does not support uifigures .
Note that you have to pass the command to be executed as a string. You cannot use, for example,
SHOW(ismember(A,B))
The restriction is because the argument is always evaluated first, and it would get executed in a context where a single output was expected, which can lead to different behaviour of the function. Compare, for example,
disp(whos)
to
whos
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Develop uifigure-Based Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!