Sophie
Sophie

Reputation: 9

Format long not working when adding to structure

I am trying to add a number in Unix time to a structure (e.g. 1.500648654999999e+09), but even when I put format long it is being saved in an abbreviated way (1.5006e+09).

 format long
    TimeToAdd = BL05_tsq_StartTimes(1) - (4*3600);
    format long
    LFPinfo(i).startTime = LFPinfo(i).startTime+TimeToAdd;

Upvotes: 0

Views: 166

Answers (1)

Y. Chang
Y. Chang

Reputation: 595

The summary of format states

Set Command Window output display format

It changes the output display format in the Command Window to the format specified by style. The computation and value stored in the memory wouldn't be affected by the format command.

To display the formatted string in the command window, you need to use fprintf, and specify the precision you prefer. For example:

fprintf('%.10f\n',LFPinfo(i).startTime)

Upvotes: 1

Related Questions