How can I format numeric arrays that are too long
Show older comments
Hi,
I am using UNIX timestamps in 2 different datasets in Matlab 2019.
eog_time=[1.556122932190000e+12
1.556123223410000e+12
1.556124030209000e+12]; %shortened sample array
flanker_time= 1.556123166337000e+09;
I want to find the closest time in eog_time to the flanker_time. However the format doesn't let me.
target=dsearchn(flanker_time, eog_time)
gives me the first value in my eog_time array.
If I delete the e+09 and e+12 parts from my arrays I will still have the necessary info and I can compare these two arrays. I tried format
format long
and
format longG
but it only works in 1 numeric value, not for the array. Any ideas how can I shorten my numbers so dsearchn would work? Or even a better way to reach the target value?
thank you.
3 Comments
I want to find the closest time in eog_time to the flanker_time
And the answer you get is correct, all the values in eog_time have a magnitude a 1000 times greater than flanker_time, so the smallest of these, the first values, is the closest.
As Jan points out in his answer, you seem to want the closest value while ignoring the magnitude. Seems like a strange comparison to me. It's like saying that 15 (1.5e1) is closer to 15000 (1.5e4) than to 10000(1.0e4).
Jan
on 23 May 2019
I guess the different magnitude are the result of useing different function for reading the values, and at least one of these methods is flawed. The clean solution would be to get the correct time stamps directly.
Hatice Sahin
on 23 May 2019
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!