changing format of number displayed on figure

조회 수: 6 (최근 30일)
D F
D F 2018년 4월 5일
댓글: D F 2018년 4월 5일
Hi, I have 2 sets of data 'a' and 'b' which I have plotted in a figure. I've then integrated under this curve using 'trapz' and then displaying this result on the figure. This is all successful however I want to change the format of the displayed number to scientific notation instead of a long number. I've used 'format longEng' but this is unsuccessful. (This is all within a for loop).
------
plot(x,y);
xlabel('x data')
ylabel('y data');
legend('Background Corrected');
title(figure_caption);
set(gca, 'YScale', 'log');
format longEng;
integration2 = trapz(x, y);
integration_text2 = 'curve integration =';
integration_info2 = [integration_text2, ' ', num2str(integration2)];
disp(integration_info2);
dim = [0 0.95 0.05 0.05];
annotation('textbox', dim, 'String', integration_info2, 'FitBoxToText', 'on');
end
------
thanks
  댓글 수: 1
Birdman
Birdman 2018년 4월 5일
Share your entire code and all necessary variables.

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

채택된 답변

Steven Lord
Steven Lord 2018년 4월 5일
The format function affects only how numeric arrays are displayed in the Command Window. To affect how they are written to a char vector or string that you can use as the String property of a graphics object, use sprintf or specify a precision or format specifier as the second input to the num2str function. See the documentation pages for those functions for examples.
  댓글 수: 1
D F
D F 2018년 4월 5일
Thanks! I've used formatspec in the num2str

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by