필터 지우기
필터 지우기

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 CenterFile Exchange에서 Large 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