Data analysis and for loop
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to create a table where I can get the timestamp at which there was fault and duration for which the fault was active. Below is my code. My code works for 1 faultcode. I have 500 fault codes. So I used a for loop to automate it and basically stuck on this point. Any leads where I can do it for 500 fault codes without inserting a fault code again? Basically what I want is a table Z for every fault code.
%Input the Fault Code
Faultcode = input('Enter the fault code - ');
% Find the Fault Pattern in the data
pattern = [Faultcode, 0];
a = transpose(Value);
idx = strfind(a, [Faultcode,0]);
result1 = reshape([idx; idx + length(pattern) - 1], 1, []);
req1 = TimeUTC(result1);
timestamp = req1(1:2:end);
date=datetime(timestamp,'ConvertFrom','datenum');
% Extract the timestamps of only fault codes where neccessary and add the
% difference
x1=req1;
h1=(x1(2:2:end) - x1(1:2:end)) * 24 * 60;
Z=table(date,h1);
댓글 수: 1
dpb
2019년 3월 20일
Need a data source that contains the fault codes; read it and then iterate over the list.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Map Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!