Azzera filtri
Azzera filtri

Importing and reading a .RAW file

105 visualizzazioni (ultimi 30 giorni)
Helen Howery
Helen Howery il 11 Gen 2021
Risposto: Walter Roberson il 14 Ott 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?

Risposte (2)

Aditya Shah
Aditya Shah il 14 Ott 2022
Hi!
Please refer to the following MATLAB Answers post with a similar issue:

Walter Roberson
Walter Roberson il 14 Ott 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');

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by