How do I split a data set into multiple chunks based on a re-occuring value?
12 次查看(过去 30 天)
显示 更早的评论
Hello all, I have an N x 2 matrix of temperature data vs time. In my first column, a value of -99999 (column 1) represents a time value (column 2), and the preceeding column 1 values after the -99999 are element numbers, while the preceeding column 2 values after the time are temperatures. Everytime there is a new time value, the column 1 value for that time will be -99999 (see .txt file). I would like to read in my .txt file, split the data into temperature vs element, vs time, and then use this data so that I can view one singular element of choice's temperature data vs time. I have attached my .txt data file so that you can see what I am working with. Thank you so much in advance!
0 个评论
采纳的回答
dpb
2022-8-19
编辑:dpb
2022-8-20
data=readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1102540/Temps.txt');
iT=(data(:,1)==-99999);
nVals=diff(find(iT));
assert(all(nVals==nVals(1)),'Unequal Number Elements In Groups')
dT=find(iT);
nVals=nVals(1)-1;
Time=seconds(repelem(data(iT,2),nVals));
ttD=timetable(Time,data(~iT,1),data(~iT,2),'VariableNames',{'Element','Temperature'});
head(ttD,5)
Use the Element variable as selection or grouping variable to compute whatever by one or group of elements.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!