We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As the subject says!
Here is my quick hack to allow complex numpy files to be read:
--- a/npy-matlab/readNPYheader.m +++ b/npy-matlab/readNPYheader.m @@ -22,8 +22,8 @@ end try - dtypesMatlab = {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','single','double', 'logical'}; - dtypesNPY = {'u1', 'u2', 'u4', 'u8', 'i1', 'i2', 'i4', 'i8', 'f4', 'f8', 'b1'}; + dtypesMatlab = {'uint8','uint16','uint32','uint64','int8','int16','int32','int64','single','double', 'logical', 'complex8', 'complex16'}; + dtypesNPY = {'u1', 'u2', 'u4', 'u8', 'i1', 'i2', 'i4', 'i8', 'f4', 'f8', 'b1', 'c8', 'c16'}; --- a/npy-matlab/readNPY.m +++ b/npy-matlab/readNPY.m @@ -20,8 +20,16 @@ try [~] = fread(fid, totalHeaderLength, 'uint8'); % read the data - data = fread(fid, prod(shape), [dataType '=>' dataType]); - + if strcmp(dataType, "complex8") == 1 + data = fread(fid, prod(shape)*2, 'single=>single'); + data = data(1:2:end) + 1j * data(2:2:end); + elseif strcmp(dataType, "complex16") == 1 + data = fread(fid, prod(shape)*2, 'double=>double'); + data = data(1:2:end) + 1j * data(2:2:end); + else + data = fread(fid, prod(shape), [dataType '=>' dataType]); + end +
The above seems to work, but not very well tested.
Thanks,
Mat
The text was updated successfully, but these errors were encountered:
Update readNPYheader.m
e532dfb
changes from: kwikteam#9
Update readNPY.m
c042089
modifications from: kwikteam#9
Updated complex reading following code at: kwikteam#9
e4381a6
No branches or pull requests
As the subject says!
Here is my quick hack to allow complex numpy files to be read:
The above seems to work, but not very well tested.
Thanks,
Mat
The text was updated successfully, but these errors were encountered: