フィルターのクリア

Import data from .DTA file to Matlab.

135 ビュー (過去 30 日間)
Mohamed Asaad
Mohamed Asaad 2022 年 2 月 10 日
コメント済み: JBA Miller 2022 年 2 月 12 日
Hi!
I need to import data from from .DTA file to plot them in MatLab. Does anybody know an appropriate way to do that? I have tried using these below scripts but no one has worked:
a1_Au1EchemPEG = fileread('John_220202_SE_SPR_PEG_PBS+HydroQ_0,45CV_1.DTA');
b1_Au1EchemPEG = strrep(a1_Au1EchemPEG,',','.');
c1_Au1EchemPEG = sscanf(b1_Au1EchemPEG, '%g', [2, inf]);
and:
a1_Au1EchemPEG = importdata('John_220202_SE_SPR_PEG_PBS+HydroQ_0,45CV_1.DTA');
b1_Au1EchemPEG = strrep(a1_Au1EchemPEG,',','.');
c1_Au1EchemPEG = cell2mat(cellfun(@str2num,b1_Au1EchemPEG ,'un',0));
  2 件のコメント
Highphi
Highphi 2022 年 2 月 10 日
can you drop a sample of the .dat file? It could very well be the case that you can't import that filetype and you'll have to export it in another application before being able to import the data.
Mohamed Asaad
Mohamed Asaad 2022 年 2 月 10 日

サインインしてコメントする。

採用された回答

Highphi
Highphi 2022 年 2 月 10 日
編集済み: Highphi 2022 年 2 月 10 日
here is what I was able to do with it:
filename = 'John_220202_SE_SPR_PEG_PBS+HydroQ_0,45CV_1.DTA';
% we really need to work on our file naming convention lol
% copy the file to a legible format
filename2 = [filename(1:end-3), 'txt'];
copyfile(filename, filename2);
% read table of legible file type
T = readtable(filename2, 'ReadVariableNames', 0);
% delete the file that we created bc we don't need it anymore
delete(filename2);
it successfully imports your file into a table
Hopefully you can take it from here, let me know if you need more assistance.
However, I must note that the end of the file you provided me has this inconsistency:
idk if that's the same for every file or even if you want to include that data since it's the same thing as the headers at the top (I'm assuming it reprints the column variable names every 900 data points)
but you're going to want to write code to parse around that or your data will be impossible to convert. lmk if you need help :)
  2 件のコメント
Mohamed Asaad
Mohamed Asaad 2022 年 2 月 10 日
WOW! What a great simply explained answer! Thank you very much!
JBA Miller
JBA Miller 2022 年 2 月 12 日
Hey!
I read through it and tried to do it myself, however when I try to read in my .dta file there is just garbage in there. Like, I got a table but it is not filled with the actual data but instead with weird signs. Maybe I did smth wrong?
Would be very happy if someone could help me out.
Best & thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by