Azzera filtri
Azzera filtri

Data analysis and for loop

1 visualizzazione (ultimi 30 giorni)
Devansh Patel
Devansh Patel il 20 Mar 2019
Commentato: dpb il 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 Commento
dpb
dpb il 20 Mar 2019
Need a data source that contains the fault codes; read it and then iterate over the list.

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by