how to have a correct array format

2 views (last 30 days)
jenny
jenny on 10 Jun 2016
Commented: jenny on 22 Jun 2016
I already set 'long g' as an array format at the variable editor preferences. However when i open the variable editor, the values for my first variable are correct, but the second variable contains values in short format. The second variable obtained after cat function. So does it relates to this? How should i change it. Thank you.
  4 Comments
Walter Roberson
Walter Roberson on 11 Jun 2016
Possibly there are only 5 or so significant decimal places in the data.
Can you save the data as a .mat, including the first variable and the second variable individually?
jenny
jenny on 22 Jun 2016
yes..it's only 5 significant decimal places. Thank you Mr Walter Roberson. I think i can solve it now :)

Sign in to comment.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 10 Jun 2016
You can display your numbers with the format of your choice
a=12.123456789,
sprintf('%.6f',a)
  1 Comment
jenny
jenny on 11 Jun 2016
The values are obtained after i run my code. First, I use sprintf to create the file name, then fscanf to read, continue with cat function to concatenate them. The values change after that.

Sign in to comment.

Categories

Find more on Numeric Types in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!