Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: datacursor, input and pause
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Urvashi

Posts: 1
Registered: 4/17/14
datacursor, input and pause
Posted: Apr 17, 2014 10:23 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

I am running the following code

clc; clear all;
load('Rat7_cfn_time');
load('Rat7_coord');
A = imread('E:\WorkBackup\Thesis\AnalyzedData\New Folder\12.tif');
B = imresize(A, 0.147);
xlimit = [36 108]; ylimit = [0 18];
xbox = xlimit([1 1 2 2 1]); ybox = ylimit([1 2 2 1 1]);

imshow(B); hold on;
mapshow(xbox,ybox);
cfn_time(:,5:6) = zeros(length(cfn_time), 2);
trial = {zeros(length(cfn_time),1)};
for i = 1:length(crossover_frame_number)
startp = crossover_frame_number(i,1); endp = crossover_frame_number(i,2);
if isnan(startp | endp)
break
else
t = startp:endp; compt = crossover_frame_number(i,3);
x = BlueX(t); y = BlueY(t);
[xi, yi] = polyxpoly(x, y, xbox, ybox, 'unique');
o = mapshow(x,y,'Marker','+');
p = mapshow(xi,yi,'DisplayType','point','Marker','o');
q = text(16, 15, num2str(crossover_frame_number(i,3)), 'Color','w','FontWeight','Bold','FontSize',30);

str1 = input('Enter outcome: Correct(c)/ Wrong(w) : ', 's');
switch str1
case 'Correct'
cfn_time(i,6) = 1;
case 'Wrong'
cfn_time(i,6) = 0;
end

str2 = input('Enter strategy: Direct(d)/ Serial(s) : ', 's');
switch str2
case 'Direct'
cfn_time(i,5) = 1;
case 'Serial'
cfn_time(i,5) = 0;
end

cross = input('Number of points to be added: ' );
index = zeros(1, 1:length(cross));

for k = 1: abs(cross)
disp(['Add entry point: ' num2str(k)])
dcm_obj = datacursormode(gcf);
set(dcm_obj,'Enable','on','SnapToDataVertex','on','DisplayStyle','datatip');
pause
point = struct2array(getCursorInfo(dcm_obj));
index(k) = point(4) + startp - 1;
end

index = {index};
dcm_obj.removeAllDataCursors;
delete(o); delete(p); delete(q);
trial(i) = index;

end
end


For every iteration 'i', I have to enter the str 1, str 2, number of crosses, followed by getting the data cursor points for each cross.
The problem is that the code runs fine for the first iteration, but all the subsequent iterations get messed up (May be because I am constantly clicking on the plot, and that gets added on as 'buttonpress', thereby not holding for the next iteration?)

This is what I get for the 1st and 2nd iteration

Enter outcome: Correct(c)/ Wrong(w) : w
Enter strategy: Direct(d)/ Serial(s) : d
Number of points to be added: 2
Add entry point: 1
Add entry point: 2

Enter outcome: Correct/ WrongEnter strategy: Direct/ SerialNumber of points to be added: 8
Add entry point1: ........ etc
Add entry point 8

Enter outcome: Correct(c)/ Wrong(w) : Enter strategy: Direct(d)/ Serial(s) : Number of points to be added: Enter outcome: Correct(c)/ Wrong(w) : Enter strategy: Direct(d)/ Serial(s) : Number of points to be added: Enter outcome: Correct(c)/ Wrong(w) : Enter strategy: Direct(d)/ Serial(s) : Number of points to be added:


Is there a good way to solve this problem? My code is not exactly perfect, so is there a better way to write the code? And is my problem related to multi threading?

Thanks,
Urvashi



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.