plot - How can I display numbers with higher precision in a MATLAB data cursor? -


i have problem precision loss. imported set of values csv file matlab 7 using following code:

function importfile(filetoread1) %#importfile(filetoread1) %#  imports data specified file %#  filetoread1:  file read  delimiter = ','; headerlines = 0;  %# import file rawdata1 = importdata(filetoread1, delimiter, headerlines);  %# simple files (such csv or jpeg files), importdata might %# return simple array.  if so, generate structure output %# matches import wizard. [~,name] = fileparts(filetoread1); newdata1.(genvarname(name)) = rawdata1;  %# create new variables in base workspace fields. vars = fieldnames(newdata1); = 1:length(vars)     assignin('base', vars{i}, newdata1.(vars{i})); end 

this basic script takes specified file:

> 14,-0.15893555  > 15,-0.24221802 > 16,0.18478394 

and converts second column to:

14  -0,158935550000000 15  -0,242218020000000 16  0,184783940000000 

however, if select point data cursor displays 3 or 4 digits of precision:

imprecise labels

is there way program higher precision more exact data points?

your data isn't losing precision, data cursor display isn't showing full precision text boxes more reasonable size. however, if want increase precision of display in text datatip, you can customize it.

if right click on data cursor text box, should see menu this:

enter image description here

if select edit text update function... option, open default m-file containing following:

function output_txt = myfunction(obj,event_obj) %# display position of data cursor %# obj          not used (empty) %# event_obj    handle event object %# output_txt   data cursor text string (string or cell array of strings).  pos = get(event_obj,'position'); output_txt = {['x: ',num2str(pos(1),4)],...     ['y: ',num2str(pos(2),4)]};  %# if there z-coordinate in position, display if length(pos) > 2     output_txt{end+1} = ['z: ',num2str(pos(3),4)]; end 

notice text x , y coordinate data formatted using num2str, second argument being 4. converts coordinate value string representation 4 digits of precision. if want more digits displayed, increase number, save newly-created m-file on path.

now datatip text should display more precision numbers. if want accomplish of above programmatically, first create text update function, save file (like 'updatefcn.m'), turn on data cursors using function datacursormode , set them use user-defined text update function. here's example:

plot(1:10,rand(1,10));    %# plot sample data dcmobj = datacursormode;  %# turn on data cursors , return                           %#   data cursor mode object set(dcmobj,'updatefcn',@updatefcn);  %# set data cursor mode object update                                      %#   function uses updatefcn.m 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -