How to read data from text file into class?
9 ビュー (過去 30 日間)
古いコメントを表示
I have txt-files such as the one attached, where there are first lines describing the data in the file and then a table containing all the numeric data. I have a class in my mat-file and within it the following properties:
classdef measurement_data
properties
t0 = 0 % [datetime] start time of the measurement in CET time. 0 if not known.
dt = 0 % [s] delta t in seconds
data = [] % [] measurement data
time = []
name = '' % name of the measured data
unit = '' % unit of the measured data
metadata = '' % additional information about the measurement. For example comment field from a measurement file.
end
end
How, now, can I read data from a text file and create objects out of the different recorded signals? Each signal in the same file has the same start time, delta t, and time, but they all have different measurement data, names, and units. In different tutorials about OOP in Matlab, I've usually just seen an example where they set the value of a property manually, for example like this:
SD1_SPEED_MEASURED_1 = measurement_data;
SD1_SPEED_MEASURED_1.dt = 300;
But how would I go about setting the value by reading it from the data?
I hope it's at least somewhat clear what I'm going for, as I would really appreciate it if someone could explain this to me or point me to some documentation that might be helpful because my googling has done little to help me.
0 件のコメント
回答 (1 件)
Oriol Brasco
2019 年 7 月 8 日
Hello,
try using uiimport (in command window). It will help you to select the data you want and save it. Also, you could generate scripts in order to automatize the data obtention. Documentation:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!