Filter löschen
Filter löschen

my question is after ploting (x,y) , i want to count the number of signals that is above 0.5 at time for example : 1.05e-7, how to do that in matlab

1 Ansicht (letzte 30 Tage)
i want to count the values from data set (:,2:5) that is above 0.5 at specific time
data_1 = load('ay.csv')
x = data_1(:,1)
y = data_1(:,2:5)
plot(x,y)
count=0
n= 17059
m=4
for r=1:n
for c=1:m
if y(r,c)> 0.5 & (x == 1.05e-7)
count= count+1
end
end
end
count
  2 Kommentare
Jan
Jan am 14 Sep. 2022
What is your question?
Does load('ay.csv') work? load works with MAT files and a specific set of text files only.
x is a vector. Then x==1.05e-7 is a vector also. The if condition must be a scalar. Therefore Matlab inserts an all() implicitly. But is this wanted?
Remember that comparisons of floating point numbers are fragile. 1.05e-7 and 1.0499999999e-7 might be displayed as the same value in the command wirndow, but they differ. Using a range is safer.
Hagar Hendy
Hagar Hendy am 14 Sep. 2022
yes loading works, my question is after ploting (x,y) , i want to count the number of signals that is above 0.5 at time for example : 1.05e-7.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Torsten
Torsten am 14 Sep. 2022
xx = 1.05e-7;
[~,i] = min(abs(x-xx));
count = nnz(y(i(1),:) > 0.5)

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by