problems with function "find". matlab doesn't match two numbere which are built equal
이전 댓글 표시
M cannot be found because Matlab says they are different, but i built them in order to be equal. length(data)=7155
clear all;clc;close all;
data0 = load('data0000.txt');
data1 = load('data0001.txt');
data2 = load('data0002.txt');
Rg=17.5;
fs = 100; % Hz
dt = 1/fs;
data= [data0; data1; data2];
time= 0:dt:(length(data)-1)*dt;
N=find(time==12.01);
M=find(time==46.5);
data=data(N:M,:);
time=time(N:M);
댓글 수: 1
Luna
2018년 10월 6일
Could you please attach data0001.txt and data0002.txt ?
채택된 답변
추가 답변 (1개)
It is better to compare floats using a tolerance
tol=0.01;
M = find(abs(time-46.5)<tol);
I was however able to find the first number, N, using your code.
N =
1202
the second number, M, is probably in another textfile because there is no value near 46.5 in the one you attached
댓글 수: 1
dpb
2018년 10월 6일
ismembertol can be useful for such purposes.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!