Effacer les filtres
Effacer les filtres

Data analysis and for loop

1 vue (au cours des 30 derniers jours)
Devansh Patel
Devansh Patel le 20 Mar 2019
Commenté : dpb le 20 Mar 2019
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 commentaire
dpb
dpb le 20 Mar 2019
Need a data source that contains the fault codes; read it and then iterate over the list.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by