'.m' Script file to read a data acquisition file with both strings and doubles

1 view (last 30 days)
Hello, I used a Wheatstone Bridge to acquire strain data that looks like this:
Date Time 0204923-Ch1ue 0204923-Ch2ue 0204923-Ch3ue 0204923-Ch4ue 06/13/14 02:24:00:6394 2305 Offscale Offscale Offscale 06/13/14 02:24:01:1547 2305 Offscale Offscale Offscale 06/13/14 02:24:01:6690 2306 Offscale Offscale Offscale
I want to write a matlab script file that reads this data and plots a graph of the time (column 2) versus the strain reading (column 3). however, I find difficulties in reading the data. I tried using both 'textscan' and 'textread' functions
My script looks like this:
clear all
% READ DATA filename = input('Enter filename: '); fid = fopen(filename,'r'); heading=fgetl(fid);
%C = dlmread(filename,'\t');
C = textscan(fid, repmat('%s',1,6), 'delimiter','whitespace', 'CollectOutput',true);
ref_time = datenum('1/1/2014 00:00:00');
C = C{1}; fclose(fid);
% Delete rows with empty cells
C(any(cellfun(@isempty,C)'),:) = [];
for i=1:r time_days(i,1) = datenum(time(i)) - ref_time; end
plot(C(:,2),C(:,3))
Thank you in advance.

Answers (0)

Community Treasure Hunt

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

Start Hunting!