Prev: find the wheel centre and radius in pixel
Next: how can I get velocity and acceleration from angular position signal.
From: Randi Price on 14 Jun 2010 11:03 Hi, I'm writing a program that will allow a user to plot a x vs. y text file and select a point on the plot using the cursor data function. The user then saves the cursor data to the workspace and can then open a new text file and see where the point they previously selected is on the new plot. This part is working perfectly, although I want to have the option of selecting a new point and rewriting the original cursor data point, using the same variable name because it will be recalled later in the program. Matlab always freezes whenever the user tries to save new cursor data with the same variable name as the old cursor data. How do I fix this? Also, when the cursor data is replotted onto a new plot, I would like it to be a vertical line instead of a point. Thank you so much in advance for your help! See the code below. Randi file1=input('Please select the file number to choose T0: ','s'); test=load (file1); x=test(:,1); y=test(:,2); plot(x,y) datacursormode on xlabel('Time (ms)') ylabel('Delta A') confirm=input('Please type "y" when cursor information has been saved to workspace: ','s'); pos=cursor_info.Position; x1=pos(:,1); y1=pos(:,2); T0=x1; [row]=find(x==T0); file2=input('Please select the next file number to evaluate T0: ','s'); test2=load (file2); x=test2(:,1); y=test2(:,2); plot(x,y) xlabel('Time (ms)') ylabel('Delta A') plot(x,y) xlabel('Time (ms)') ylabel('Delta A') hold on plot(x1,y1,'MarkerSize',16,'Marker','.','LineWidth',4,'LineStyle','none',... 'Color',[1 0 0]); choice = menu('Choose an option:','Keep T0, check another file','Keep T0, process data','Choose a new T0') ; w=1; while w==1 if choice==1 w=1; file2=input('Please select the next file number to evaluate T0: ','s'); test2=load (file2); x=test2(:,1); y=test2(:,2); choice=0; plot(x,y) xlabel('Time (ms)') ylabel('Delta A') plot(x,y) xlabel('Time (ms)') ylabel('Delta A') hold on plot(x1,y1,'MarkerSize',24,'Marker','.','LineWidth',4,'LineStyle','none',... 'Color',[1 0 0]); choice = menu('Choose an option:','Keep T0, check another file','Keep T0, process data','Choose a new T0') continue elseif choice==2 w=0; continue elseif choice==3 w=1; file1=input('Please select the file number to choose T0: ','s') test=load (file1) x=test(:,1) y=test(:,2) plot(x,y) datacursormode on xlabel('Time (ms)') ylabel('Delta A') confirm=input('Please type "y" when cursor information has been saved to workspace: ','s') pos=cursor_info.Position x1=pos(:,1) y1=pos(:,2) file2=input('Please select the next file number to evaluate T0: ','s') test2=load (file2) x=test2(:,1) y=test2(:,2) T0=y plot(x,y) xlabel('Time (ms)') ylabel('Delta A') plot(x,y) xlabel('Time (ms)') ylabel('Delta A') hold on plot(x1,y1,'MarkerSize',24,'Marker','crosshair','LineWidth',4,'LineStyle','none',... 'Color',[1 0 0]); choice = menu('Choose an option:','Keep T0, check another file','Keep T0, process data','Choose a new T0') continue end end |