Importing and reading a .RAW file
    조회 수: 123 (최근 30일)
  
       이전 댓글 표시
    
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?
댓글 수: 0
답변 (2개)
  Aditya Shah
    
 2022년 10월 14일
        Hi!
Please refer to the following MATLAB Answers post with a similar issue:
댓글 수: 0
  Walter Roberson
      
      
 2022년 10월 14일
                    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');
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


