Display array values of varying orders of magnitude
조회 수: 1 (최근 30일)
이전 댓글 표시
I store a function's input parameters in an array, and I want the values in the array printed in the Command Window when an error occurs.
The array's values span many orders of magnitude (1e-4 up to 1e16). When printed, at the top of the printed data one sees "1.0e+16 *" and then underneath each array value listed as a zero, except that which is on the order of 1e16. That is listed as a number between 1 and 10.
Is there an easy way to print all values of the array in their own respective order of magnitude?
댓글 수: 0
채택된 답변
Matt Tearle
2012년 1월 18일
fprintf with the e format will put everything in exponential notation:
x = [1.234e16,42;0.3,6.789e8]
fprintf([repmat('%7.4e ',1,size(x,2)),'\n'],x')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!