Why I can't display all the decimal digits in a plot?

My code converts a 2-columns string array (first image) into a 2-columns double array. After the conversion, the numbers in the matrix are cut off after the 4th decimal digits (second image) (I need 6 decimal digits) and if I plot the data, only the time axis values are cut off, this time after the 2nd decimal digit! (third figure) while the y axis data have all the 6 decimal digits required. How is it possible ?
<<
>>

 채택된 답변

KL
KL 2017년 8월 8일
format long

댓글 수: 4

This command is to display numbers in the command window, it doesn't work on charts.
KL
KL 2017년 8월 11일
편집: KL 2017년 8월 11일
Do you want the data cursor to have more accuracy?
function txt = myupdatefcn(empt,event_obj,str)
pos = get(event_obj,'Position');
px = sprintf(str,pos(1));
py = sprintf(str,pos(2));
txt = {['X: ' , px],['Y: ' , py]};
end
and
function ret = fixplot1(str),
set(datacursormode(gcf),'UpdateFcn',{@myupdatefcn, str});
end
and then call it like this,
plot(1:0.0000001:1.5), fixplot1('%1.8f');
found this here .
That's what I was looking for, Thank you very much!
Perfect solution. I was looking for the same thing too.
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Ata ur rahman Mohammed
Ata ur rahman Mohammed 2019년 10월 28일

2 개 추천

The better solution is just update the number of decimal points in "text function". In data cursor mode, right click and select "edit text update function", in the variable output_txt= 'X: '. num2str(pos(1),4)]; update the 4 to 6 or 10, this defines total number of digits on the X axis data display. Hope this helps. Found from ALEX WINTEER's Commenthttps://groups.google.com/forum/#!searchin/comp.soft-sys.matlab/subject$3A%22Data$20cursor$20precision%22/comp.soft-sys.matlab/xEJlCB_e-X8/gMDlZZC7vb0J

댓글 수: 3

It wasw useful for me, thanks!
Badrul Huda Husain
Badrul Huda Husain 2020년 8월 19일
편집: Badrul Huda Husain 2020년 8월 19일
Hi.. I'm quiet new in Matlab..would you guys tell me which command do I have to edit to make coordinate position digits more precise ? I try to following your discussion to edit "text function"in matlab R2020a
..I am attaching photo from my Matlab command
It was very helpful for me!
Thank you very much!

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2017년 8월 10일

1 개 추천

You are using the Variable viewer. See the Preferences to use long format instead of short.

댓글 수: 2

What you suggested me is the same KL told me in his first answer to put
format long
but in this way, I can fix only the numbers shown in the command windows. Thank you anyway for your answer.
This is not the same as "format long". "format long" only affects displaying values to the command window. The Preferences affects the format of the Variable Browser.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 8월 8일

댓글:

2020년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by