-
Notifications
You must be signed in to change notification settings - Fork 1
/
read_testdata_sci.m
executable file
·35 lines (34 loc) · 1.29 KB
/
read_testdata_sci.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
%--function to read in load - CMOD test data
function [testdata]= read_testdata_sci
[FileName2,PathName2] = uigetfile({'*.txt'},'Select File');
if FileName2 == 0
return;
end
handles.FullFileName2 = strcat(PathName2,FileName2);
handles.FileName2 = FileName2;
handles.PathName2 = PathName2;
testdata.testdata_filename = FileName2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [Text] = textread(handles.FullFileName2, '%[^\n]');
fid = fopen(handles.FullFileName2, 'rt');
ts = textscan(fid, '%[^\r\n]');
Text = ts{1};
% data_index = strmatch('*CMOD', Text);
data_index = find_string_index('*CMOD',Text);
if isempty(data_index)
errordlg('"*CMOD" keword not found, please import a test data file with the appropriate format');
else
% end_data_index = strmatch('*end_test_data', Text);
end_data_index = find_string_index('*end_test_data');
data_length = end_data_index-data_index-1;
for i = 1:data_length
%use textscan to allow reading of tab, space, or comma delimited
%data
testdata.CMOD_cell(i) = textscan(Text{data_index+i},'%f %*f', 'delimiter', ',');
testdata.force_cell(i) = textscan(Text{data_index+i},'%*f %f', 'delimiter', ',');
%pull out of cell array
testdata.CMOD(i) = testdata.CMOD_cell{i};
testdata.force(i) = testdata.force_cell{i};
end
end
end