フィルターのクリア

How can I move to the next trial without generating new window of figure?

2 ビュー (過去 30 日間)
Jinah Lee
Jinah Lee 2017 年 3 月 17 日
コメント済み: Jinah Lee 2017 年 3 月 17 日
I'm working on generating attention shift task. And I'm very beginner of MATLAB. When I run this code, it kept generating new figure window. However, I want to make it goes to the next trial without generating new window with the figure. Could someone tell me what did I wrong? Thanks a lot!
DATA = zeros(80,1); % pre-allocation of data matrix
ExoHorizentalV100 = 0;
jj = 1;
while ExoHorizentalV100 < 80
coin = rand;
if coin < 0.5 % cue and target presented in the right
fig = figure;
set(fig,'position',get(0,'ScreenSize'))
r1 = rectangle('position',[0,150,100,100],'EdgeColor','k','Linewidth',3);
xlim([0 400])
ylim([0 400])
hold on
plot(200,200,'+','MarkerSize',30,'LineWidth',3,'Color','k');
hold on
r2 = rectangle('position',[300,150,100,100],'EdgeColor','k','Linewidth',3);
axis square;
axis off;
pause(4)
t = text(180,270,'\rightarrow','FontSize',40,'LineWidth',3,'Color','k');
pause(0.1)
set(t,'Visible','off')
plot(350,200,'kp','MarkerSize',30,'MarkerFaceColor','k')
pause(0.3)
elseif coin > 0.5 % cue and target presented in the left
fig = figure;
set(fig,'position',get(0,'ScreenSize'))
r1 = rectangle('position',[0,150,100,100],'EdgeColor','k','Linewidth',3);
xlim([0 400])
ylim([0 400])
hold on
plot(200,200,'+','MarkerSize',30,'LineWidth',3,'Color','k');
hold on
r2 = rectangle('position',[300,150,100,100],'EdgeColor','k','Linewidth',3);
axis square;
axis off;
pause(4)
t = text(180,270,'\leftarrow','FontSize',40,'LineWidth',3,'Color','k');
pause(0.1)
set(t,'Visible','off')
plot(50,200,'kp','MarkerSize',30,'MarkerFaceColor','k')
pause(0.3)
end
tic; pause ; temp = toc;
response = get(fig,'CurrentCharacter');
ExoHorizentalV100 = ExoHorizentalV100 + 1;
DATA(jj,1) = temp;
jj = jj + 1;
end

採用された回答

Greg
Greg 2017 年 3 月 17 日
Take
fig = figure;
set(fig,'position',get(0,'ScreenSize'))
out of the loop

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by