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 回表示 (過去 30 日間)
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 件のコメント
Jan
Jan 2022 年 9 月 14 日
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 2022 年 9 月 14 日
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.

サインインしてコメントする。

回答 (1 件)

Torsten
Torsten 2022 年 9 月 14 日
xx = 1.05e-7;
[~,i] = min(abs(x-xx));
count = nnz(y(i(1),:) > 0.5)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by