Data analysis and for loop

1 次查看(过去 30 天)
Devansh Patel
Devansh Patel 2019-3-20
评论: dpb 2019-3-20
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
dpb 2019-3-20
Need a data source that contains the fault codes; read it and then iterate over the list.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by