Read/Write Data from .dat file Problem

1 Ansicht (letzte 30 Tage)
younes
younes am 2 Sep. 2024
Bearbeitet: Walter Roberson am 3 Sep. 2024
Hello,
i have 2 files ".dat" containes enum values and i Read this files by using comand "readmatrix" the problem its when i want to Combine this Two files in one file by using this scripte ,show me a error:
A=readmatrix('DMIR22345.Dat');%Read first file.dat
B=readmatrix('DMIR2235.Dat');%Read sconde file.dat
C=[A;B]; %Combine 2 files
csvwrite('Data1.dat', C);% Creat New file 'Data1.dat' Contains Data of file 1 and file 2
Error: after running the scripte i have this error because the size of "A" its (15761x34) Complex double and "B" its (15794x2) double :
so to resolve the error i used this scripte:
% Assuming A has more columns than B
numColsA = size(A, 2);
numColsB = size(B, 2);
if numColsA > numColsB
B(:, end+1:numColsA) = 0; % Pad B with zeros
elseif numColsB > numColsA
A(:, end+1:numColsB) = 0; % Pad A with zeros
end
% Now concatenate
C = [A; B];
csvwrite('Data1.dat', C);
it Work but when i want to Read the file "Data1.dat" by using MDA Software to see the sgnals ,didn't work and show a Msg:
Can You Help me Guys
Thank you
  3 Kommentare
Star Strider
Star Strider am 2 Sep. 2024
‘... the size of "A" its (15761x34) Complex double and "B" its (15794x2)
There is simply no way that you can concatenate those files. I have no idea what the software expects, however consider padding it with NaN rather than zeros. Zero elements have value, NaN elements do not.
The only reference I can find for ‘MDA Software’ is: https://www.mdasoft.in/. That does not tell me anything about specific file formats it may require.
dpb
dpb am 2 Sep. 2024
Bearbeitet: dpb am 3 Sep. 2024
"...the size of "A" its (15761x34) Complex double and "B" its (15794x2) double : "
Besides the size mismatch, the two data types are different -- one is complex and the other isn't.
Why would you think these two files should be concatenated in the first place when they are completely disparate in content as well as size?
This is absolutely nothing like the previous Q? you asked about putting together two files each of whch was two-colums of type double, just different lengths. That makes sense in at least creating one long file from two; this request simply makes no sense at all as to why one would even consider doing such a thing.
As @Star Strider notes, it cannot be done in any straightforward way, and it is, I'm sure even without knowing what MDA software is that any result you get by doing so, now matter how you force it, will NOT be anything MDA will be able to do anything with. The link to "Products" from the home page link @Star Strider is empty so what particular MDA Software product you have/want to use is anybody's guess.
In order to provide any useful help, as the barest minimum we would have to know what the target application is that you're trying to use, its expectations for input and what the two files in question represent with respect to that application reading and doing something with them.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 3 Sep. 2024
Bearbeitet: Walter Roberson am 3 Sep. 2024
A = readmatrix('DMIR22345.Dat');%Read first file.dat
B = readmatrix('DMIR2235.Dat');%Read sconde file.dat
filename = 'Data1.dat';
writematrix(A, filename);
writematrix(B, filename, 'WriteMode', 'append');

Kategorien

Mehr zu Standard File Formats finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by