How to find a specific number in a specific column in an excel file and how many times it occurs

2 Ansichten (letzte 30 Tage)
Hi, I have been looking around for a solution to this problem, I have an excel file and it contains the number -1100 in the column with header "T". I want to find out how many times this number occurs in this given column. So I tried
[~, ~, data] = xlsread('test.xlsx');
data = string(data); % convert to string for easy comparision
rowsIndex = data(:, 1) == "T" && data(:, 2) == "-1100";
requiredRows = data(rowsIndex, :);
but this does not work. How can I find the number of times it occurs in the T column?
Thanks

Akzeptierte Antwort

VBBV
VBBV am 31 Jan. 2024
D = readtable('test.xlsx');
rowsIndex = D.T == -1100;
requiredRows = D(rowsIndex, :)
requiredRows = 17×12 table
REGNR T T64 T65 T79 T80 T83 T84 T87 T88 T97 T98 _____ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ 9 -1100 191.38 191.29 191.34 190.62 191.41 191.03 191.38 190.44 190.91 191.03 12 -1100 194.52 193.4 194.3 193.16 194.81 193.75 194.07 193.03 195.2 195.72 23 -1100 193.87 193.3 193.5 191.49 193.62 192.14 193.23 191.18 192.28 192.66 28 -1100 191.74 191.73 191.65 191.72 191.77 191.84 191.77 191.74 191.53 191.53 118 -1100 191.33 189.7 191.23 191.13 191.32 191.31 191.39 191.25 191.27 191.2 172 -1100 189.74 189.47 189.71 189.5 189.88 189.77 189.87 189.58 189.77 189.75 365 -1100 237.13 190.19 235.62 206.26 238.91 214.46 223.89 202.74 218.9 227.26 366 -1100 191.31 142.71 191.25 191.48 191.34 191.51 191.45 191.69 191.27 191.2 561 -1100 195.96 143.38 195.2 193.84 195.15 194.57 194.74 193.63 194.32 194.61 755 -1100 195.34 145.73 194.65 193.44 194.53 194.4 194.25 193.3 193.88 194.13 956 -1100 192.45 158.16 192.34 192.01 192.41 192.33 192.43 192.01 192.16 192.16 1052 -1100 191.47 139.29 191.45 191.22 191.55 191.49 191.65 191.26 191.42 191.4 1053 -1100 191.45 144.82 191.44 191.16 191.53 191.46 191.63 191.17 191.38 191.37 1111 -1100 191.76 149.01 191.74 191.54 -1100 191.83 191.84 191.59 191.77 191.72 1131 -1100 192.45 161.37 192.43 192.33 -1100 192.53 192.51 192.46 192.47 192.4 1133 -1100 192.1 144.37 192.01 191.93 -1100 192.11 192.13 192.07 192.03 191.97
  4 Kommentare
Sergio
Sergio am 31 Jan. 2024
I tried with
D = readtable('hakansexempeldata1.xlsx');
rowsIndex = D.T == -1100;
requiredRows = D(rowsIndex, :)
C = size(requiredRows,1)
got C =
17
so it would be 17 times

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by