Index in position 1 exceeds bounds
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I don't exactly see what I am doing wrong on or missing in index. But setting up the Date array probably off.
Thanks
Marv.
ERROR
Index in position 1 exceeds array bounds.
Error in Data_Analyzer (line 47)
Date{1,6} = str2num(Date{1,6})/1000;
CODE ...
clear clear all();
directory1 = pwd;
Folder1 = '\TDMS Read';
Folder2 = '\Figures';
Folder3 = '\Reports';
directory2 = sprintf('%s%s',directory1,Folder1);
directory3 = sprintf('%s%s',directory1,Folder2);
directory4 = sprintf('%s%s',directory1,Folder3);
cd(directory2);
TDMS = TDMS_readTDMSFile('C:\Users\e422425\Documents\MATLAB\TDMSData\TDMS Read\Practice_Data2.tdms');
DataSize = size(TDMS.data,2);
DataSize = 23
filename = 'Max_Min_Mean.xlsx';
cd(directory1);
header = {'Sensor Designator','Max','Min'};
ChanExtrData = cell(DataSize + 1,3);
ChanExtrData(1,:) = header;
%%First Motion Circuit
N = 23;
z1 = 0;
y = TDMS.data(1,N);
%Get Channel Name
c = TDMS.dataType(1,N);
if c == 10
%Channel Information is pulled from x.propertyValues from this we derive
%the individual channels start time and time differential/sample rate
y = cell2mat(y);
z = TDMS.propValues(1,N);
z1 = z1+1;
NameArray = TDMS.chanNames(1,1);
ChanName = NameArray{1}{1,z1};
TimeStamp = z{1}{1,26};
TimeDiff = z{1}{1,24};
[ThrowAway,First_Motion_Index] = size(y);
Date = regexp(TimeStamp,'\d*','Match');
Date{1,6} = str2num(Date{1,6})/1000;
Date{1,5} = str2num(Date{1,5});
0 Commenti
Risposte (1)
Voss
il 21 Mag 2024
Modificato: Voss
il 21 Mag 2024
Check the value of TimeStamp and figure out why it's not what you expect, because regexp doesn't return any matches for that TimeStamp. Example:
TimeStamp = 'kljsdfh';
Date = regexp(TimeStamp,'\d*','Match')
try
Date{1,6}
catch e
e.message
end
If there were at least one match but fewer than 6 matches, you'd get a different error. Example:
TimeStamp = 'kljs55dfh';
Date = regexp(TimeStamp,'\d*','Match')
try
Date{1,6}
catch e
e.message
end
2 Commenti
Voss
il 22 Mag 2024
Modificato: Voss
il 22 Mag 2024
You're welcome!
You may want to set a breakpoint or use dbstop if error in order to check the value of TimeStamp just before the error happens.
Vedere anche
Categorie
Scopri di più su Time Series Objects 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!