Changing the shape of a wave increased the number of significant digits, somehow
Jay
Hi all,
I have a delimited text file in which all the values are in a row, separated by tabs. When I load the delimited text, it results in a 2D wave, which has 1 row and N columns. I make a new wave that stores the data in a 1D wave of length N. But what I find is that the values in this new wave have more significant digits. Where did those significant digits come from? What's going on? The following output from the command window demonstrates the issue. I've also included the delimited text file.
•LoadWave/J/M/D/N=wave/K=1 filePath
Delimited text load from "SensiScanXPerp_262"
Matrix size: (1,81), wave: wave0
•Make/O/N=(DimSize(wave0, 1)) transposed = wave0[0][p]
•Print/D wave0[0][0]
-3.721381
•Print/D transposed[0]
-3.72138094902039
Delimited text load from "SensiScanXPerp_262"
Matrix size: (1,81), wave: wave0
•Make/O/N=(DimSize(wave0, 1)) transposed = wave0[0][p]
•Print/D wave0[0][0]
-3.721381
•Print/D transposed[0]
-3.72138094902039
(P.S. If there's a one-line command that will read my delimited text file into a 1D wave rather than a 2D wave, I'd love to know it.)
Hi Jay,
a similar case with suddenly appearing digits was discussed about three weeks ago: https://www.wavemetrics.com/forum/general/str2num-and-scientific-notation-behavior
The problem arises because you load the data with double precision but the wave for the transposed data has only single precision. You will get the desired result when you use:
Make/D/O/N=(DimSize(wave0, 1)) transposed = wave0[0][p]
However, I have no suggestion for a one-liner...
Best, Klaus
August 1, 2023 at 12:45 pm - Permalink
Thanks Klaus! That did indeed solve my problem.
August 1, 2023 at 01:07 pm - Permalink
Sidenote: You do not need to create a new wave to transpose your data. Just use MatrixTranspose:
MatrixTranspose wave0
August 1, 2023 at 09:44 pm - Permalink
Redimension/E=1/N=(DimSize(wave0, 1)) wave0
should do the trick or?
August 3, 2023 at 10:54 am - Permalink