Filter löschen
Filter löschen

Importing and reading a .RAW file

105 Ansichten (letzte 30 Tage)
Helen Howery
Helen Howery am 11 Jan. 2021
Beantwortet: Walter Roberson am 14 Okt. 2022
Hello!
I am a newbie MATLAB user and need to import/load/read a .RAW file. This portion of code is going into appdesigner and I will be using the data for graphs and such. To start with, I just the command window to see what the import function actually take in:
data = importdata('Sertta_Sample_Data.raw')
data =
struct with fields:
data: [107×20 double]
textdata: {109×21 cell}
I know that the textdata should be the first 2 rows and then the first 3 columns so I am confused on what 109x21 means. That is my first question, what is this actually importing? Second, is this actually usable to read/graph/etc.? After this, I am writing the following code:
%load the data
data = importdata('Sertta_Sample_Data_12_17_2020_3_09_03_PM_.raw');
%Check Intramentation
TS = string(app.InstrumentationListBox.Value);
if TS == "TS-101"
%Defines the 2nd column as the timeStr variable, converts it into datenum format, and then converts it into datetime format.
dates = datetime(data(1:end-1,1),'Format','MM/dd/yyyy HH:mm:ss.SSS');
timeStr = data(1:end-1,1);
timeNum = datenum(timeStr);
times = datetime(timeNum,'ConvertFrom','datenum','Format','MM/dd/yyyy HH:mm:ss.SSS');
%Add dates to times since they are both in datetime format
CombinedDT = dates+timeofday(times);
Temp1 = data{1:end-1,2}; %Assuming all files have the same column formats,
plot(CombinedDT,Temp1,CombinedDT);
datetick('x','dd-mmm hh:MM','keepticks');
set(gca,'XTickLabelRotation',60);
grid on
But am getting an error code of:
Error using datetime (line 659)
Input data must be a numeric array, a string array, a cell array containing character vectors, or a char matrix.
My third question is: Is this just because of how I am loading in the .RAW file? If not, how do I fix this?

Antworten (2)

Aditya Shah
Aditya Shah am 14 Okt. 2022
Hi!
Please refer to the following MATLAB Answers post with a similar issue:

Walter Roberson
Walter Roberson am 14 Okt. 2022
data = importdata('Sertta_Sample_Data_12_17_2020_3_09_03_PM_.raw');
According to your display of the result of importdata(), importdata() is returning a struct with two fields. You need to select the appropriate part of structure, such as
dates = datetime(data.data(1:end-1,1),'Format','MM/dd/yyyy HH:mm:ss.SSS');

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by