Based on Column 3 values how to get specific column 1 values?

1 visualizzazione (ultimi 30 giorni)
I have 3 columns of data coming from excel, Please find attached txt file, for instance in the attached txt file when column C is '0', i would like to get the value of column A at that point and the two more values above it i.e 2301,2300,2244 in the attached file.

Risposta accettata

jonas
jonas il 23 Ott 2018
Modificato: jonas il 24 Ott 2018
fid = fopen('sample.txt')
out = textscan(fid,'%f%f%f','headerlines',1);
fclose(fid)
A = cell2mat(out);
id0 = find(A(:,3) == 0);
idc = [id0,id0-1,id0-2];
idc = unique(idc)
idc(idc<1) = [];
A(idc, 1)
ans =
2244 2300 2301
works for multiple zeros as well
  6 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by