Add time column to Matlab .MAT file export
Quote from brto on 26/10/2021, 13:47Hello,
When exporting to Matlab .MAT file from the RTSA File Reader block, I get a mat file with IQ data only. But there is no time column. See below for my workspace after loading the file into matlab. Would it be possible to have a time variable added to the .mat file.
The CSV file export has a time column (and maybe other file format), but not the .mat file. The IQ data is single precision, so I guess the time would also be single precision 7 Decimal Places. This would be 100ns resolution. Is that enough?
>> load('xxx.mat')
>> whos
Name Size Bytes Class AttributesIQ 2x284167060 2273336480 single
Best regards,
Brian
Hello,
When exporting to Matlab .MAT file from the RTSA File Reader block, I get a mat file with IQ data only. But there is no time column. See below for my workspace after loading the file into matlab. Would it be possible to have a time variable added to the .mat file.
The CSV file export has a time column (and maybe other file format), but not the .mat file. The IQ data is single precision, so I guess the time would also be single precision 7 Decimal Places. This would be 100ns resolution. Is that enough?
>> load('xxx.mat')
>> whos
Name Size Bytes Class Attributes
IQ 2x284167060 2273336480 single
Best regards,
Brian
Quote from AdminTC on 28/10/2021, 13:09No problem but since Matlab is a binary, and we are no cracks in the usage of Matlab, we simply need the information how to add/integrate it to the data format:
if (mFirstPacket) { struct MatHeader { char mName[116]; quint32 mSubSysLow, mSubSysHigh; quint32 mFlags; quint32 mMatTag; quint32 mMatSize; quint32 mMatFlagsTag; quint32 mMatFlagsSize; quint32 mMatFlagsLow, mMatFlagsHigh; quint32 mMatDimTag; quint32 mMatDimSize; qint32 mMatDims[2]; quint16 mMatNameTag, mMatNameSize; char mMatName[4]; quint32 mMatDataTag; quint32 mMatDataSize; } header = {0}; memset(header.mName, ' ', 116); strcpy(header.mName, "RTSA"); header.mSubSysLow = header.mSubSysHigh = 0; header.mFlags = 0x4d490100; header.mMatTag = 0x0000000e; header.mMatSize = packet->mType->mSampleSize * sizeof(float) * mTotalSamples + 12 * 4; header.mMatFlagsTag = 0x00000006; header.mMatFlagsSize = 8; header.mMatFlagsLow = 0x00000007; header.mMatFlagsHigh = 0x00000000; header.mMatDimTag = 0x00000005; header.mMatDimSize = 8; header.mMatDims[0] = packet->mType->mSampleSize; header.mMatDims[1] = mTotalSamples; header.mMatNameTag = 0x0001; header.mMatNameSize = 2; if (packet->mType->mPayloadType == DSPT_IQ) strcpy(header.mMatName, "IQ"); else strcpy(header.mMatName, "SP"); header.mMatDataTag = 0x00000007; header.mMatDataSize = packet->mType->mSampleSize * sizeof(float) * mTotalSamples; mFile.write((char *)&header, sizeof(MatHeader)); } size_t sampleSize = packet->SampleDataSize(); for(quint32 i=startIndex; i<endIndex; i++) { mFile.write((char *)(packet->SampleDataPtr(i)), sampleSize); }
No problem but since Matlab is a binary, and we are no cracks in the usage of Matlab, we simply need the information how to add/integrate it to the data format:
if (mFirstPacket) { struct MatHeader { char mName[116]; quint32 mSubSysLow, mSubSysHigh; quint32 mFlags; quint32 mMatTag; quint32 mMatSize; quint32 mMatFlagsTag; quint32 mMatFlagsSize; quint32 mMatFlagsLow, mMatFlagsHigh; quint32 mMatDimTag; quint32 mMatDimSize; qint32 mMatDims[2]; quint16 mMatNameTag, mMatNameSize; char mMatName[4]; quint32 mMatDataTag; quint32 mMatDataSize; } header = {0}; memset(header.mName, ' ', 116); strcpy(header.mName, "RTSA"); header.mSubSysLow = header.mSubSysHigh = 0; header.mFlags = 0x4d490100; header.mMatTag = 0x0000000e; header.mMatSize = packet->mType->mSampleSize * sizeof(float) * mTotalSamples + 12 * 4; header.mMatFlagsTag = 0x00000006; header.mMatFlagsSize = 8; header.mMatFlagsLow = 0x00000007; header.mMatFlagsHigh = 0x00000000; header.mMatDimTag = 0x00000005; header.mMatDimSize = 8; header.mMatDims[0] = packet->mType->mSampleSize; header.mMatDims[1] = mTotalSamples; header.mMatNameTag = 0x0001; header.mMatNameSize = 2; if (packet->mType->mPayloadType == DSPT_IQ) strcpy(header.mMatName, "IQ"); else strcpy(header.mMatName, "SP"); header.mMatDataTag = 0x00000007; header.mMatDataSize = packet->mType->mSampleSize * sizeof(float) * mTotalSamples; mFile.write((char *)&header, sizeof(MatHeader)); } size_t sampleSize = packet->SampleDataSize(); for(quint32 i=startIndex; i<endIndex; i++) { mFile.write((char *)(packet->SampleDataPtr(i)), sampleSize); }