1

forループ内で注釈を使用して、matlab図にデータを表示しようとしています。したがって、最初の反復ではファイルが機能し、2回目の反復からデータが上書きされます。次の画像のようなものです。前のテキストをクリアして、すべての反復でその反復で生成された正しいデータが表示されるようにする方法を教えてください。 ここ.

これのための私のコードは次のとおりでした-

fig3=figure;
for i=1:10
...
...
D=distance(a,b);
figure(fig3), imshow(result_images{i},'InitialMagnification', 'fit');
annotation('textbox',...
[0 0.45 0.35 0.1],...
'String',['Measured Distance=' num2str(D)],...
'FontSize',40,...
'FontName','Arial',...
'EdgeColor',[1 1 0.9],...
'Color',[0.84 0.16 0]);
end
4

2 に答える 2

2

最も効率的な解決策は、ハンドルを介して注釈を再利用することです。

% create the annotation and save its handle
h = annotation(...); % set all your formatting prefs with any string

for i=1:10,
    % do something to update D ...
    set(h,'String',['Measured Distance=' num2str(D)]); % fast and easy
end
于 2013-09-25T02:06:23.073 に答える
1

最も簡単な解決策は、注釈に特定のタグを追加することです。

%# create the annotation
annotation('textbox',...
[0 0.45 0.35 0.1],...
'String',['Measured Distance=' num2str(D)],...
'FontSize',40,...
'FontName','Arial',...
'EdgeColor',[1 1 0.9],...
'Color',[0.84 0.16 0],...
'Tag' , 'somethingUnique');

%# delete the annotation
delete(findall(gcf,'Tag','somethingUnique'))

参考:図から注釈を削除

于 2013-09-25T02:03:48.037 に答える