MATLAB: Getting mouse coordinates with x and y attached to them and displaying them in excel.

mousexy

Hello, everybody
A have an issue, I am trying to display the xy coorsdinates of the mouse clicks to an excel sheet. The things is that I am only able to write the numbers but cannot attach x or y to the assigned cell.
here's the code:
[x,y]=ginput(50200)
sheet=1;
xlRange = 'A2';
xlswrite('coordinates.xls',x,sheet,xlRange);
ylRange = 'B2';
xlswrite('cncface.xls',y,sheet,ylRange);
So, my question is, how can i get the coordinates along with 'x' or 'y' attached to them? Displaying the coordinates several times.
Thank you.

Best Answer

Convert x and y to cell arrays with the desired leading text ('x' or 'y'):
xs = [ repmat('x', size(x)), num2str(x)];
ys = [ repmat('y', size(y)), num2str(y)];
Now call xlswrite with xs instead of x, and ys instead of y.