フィルターのクリア

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 件)

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by