2つの画像を待機時間​毎に繰り返し出力する​と画像がちらつきます​。対策を教えてくださ​い。

11 views (last 30 days)
Nagao
Nagao on 29 Jan 2017
Edited: Jiro Doke on 30 Jan 2017
2つの画像を待機時間毎に繰り返し出力すると画像がちらつきます。 1つの画像出力では問題ないですが、2つの画像出力ではちらつきます。 以下にサンプルコードを示します。 プログラム実行後、figure(1)とfigure(2)をドラッグ&ドロップで離してください。
T = timer('TimerFcn',@(~,~)disp('Fired.'),'StartDelay',0.5);
for i=1:1:30
figure(1)
z=ones(100);
image(z)
figure(2)
z=ones(100);
image(z)
start(T)
wait(T)
end
使用しているPCは、windows7、プロセッサ:xeon(r) CPU E5-2609 0,メモリ:64GB
以上、よろしくお願いします。

Accepted Answer

Tohru Kikawada
Tohru Kikawada on 30 Jan 2017
"ちらつき"は figure がそれぞれアクティブになり、前面に移動するため発生していると思います。
figure 自体は操作せずに、直接 image のハンドラーを経由して値を変更することができます。
下記のコードをお試しください。
T = timer('TimerFcn',@(~,~)disp('Fired.'),'StartDelay',0.5);
figure(1);
z=rand(100,100,3);
h1 = image(z);
figure(2);
z=rand(100,100,3);
h2 = image(z);
for i=1:1:30
z1 = rand(100,100,3);
h1.CData = z1;
z2 = rand(100,100,3);
h2.CData = z2;
start(T)
wait(T)
end
このようなオブジェクトのプロパティへのアクセスは下記のヘルプが参考になります。 https://www.mathworks.com/help/matlab/creating_plots/access-and-modify-property-values.html

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!