Save ginput values under a for loop

조회 수: 5 (최근 30일)
Maria Gonzalez
Maria Gonzalez 2016년 2월 1일
답변: David Young 2016년 2월 1일
Hi I wanted to save values obtained from ginput inside a loop and create an array with those, my for loop looks like:
for index=1:24
figure('Position',[1 1 scrsz(3)*0.9 scrsz(4)*0.9]);
plot(t*1000, TRnorm(:,index), 'b');
hold on;
plot(t*1000, TRACES(:,index)/max(TRACES(:,index)), 'k');
plot([T(index) T(index)],[1 -1], 'r');
title(['Shot at ',D,' m and geophone at ', num2str(x(index)),' m'])
[B,A]=ginput;
end
So as i do get 24 images one by one and get to select a ginput point in each, it doesn't save the values in A and B. I would like to store all the values of B and A I selected in arrays, how can i do that?
Thanks!!

답변 (1개)

David Young
David Young 2016년 2월 1일
Just replace
[B,A]=ginput;
with
[B(index), A(index)] = ginput;
to store each pair of inputs in array elements. Ideally preallocate your arrays before the loop starts with
A = zeros(1, 24);
B = zeros(1, 24);

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by