MATLAB: What’s wrong with ‘smooth’ and ‘find’ commands in this code faq6.1findsmooth x = [0 0 0 1 1 1 0 1 0 0 1 1 1 0 0 0 0]; y = smooth(x,5); find(y(:) == 0.6) ans = Empty matrix: 0-by-1 Running above script gives empty matrix though definitely 0.6 elements exit. What have I done wrong? Best Answer Look at result of this line:y- round(y*10)/10In vector y there is no exact 0.6 value.Try this code:x = [0 0 0 1 1 1 0 1 0 0 1 1 1 0 0 0 0];y = smooth(x,5);find(abs(y(:)-0.6)<eps) Related SolutionsMATLAB: Dicarding the mth binary digit A(:,2:end) MATLAB: Calculation with numbers with maximum 3 nonzero digits gives a result with more then 3 nonzero digits This is the limitation of using limited number of binary numbers to represent a real-word value. Even with double precision (8 bytes or 64 bits) floating point data type, it's still impossible to represent every real-world value without errors.>> num2str(0.541,'%2.30f')ans =0.541000000000000040000000000000>> num2str(16,'%2.30f')ans =16.000000000000000000000000000000 Related QuestionWhat is the difference between ‘smooth’ and ‘smoothdata’ functionCannot get the same result in GA as I get in linprogWhat is the difference between ‘smooth’ and ‘filter’ function for smoothingFinding series of repeating numbers in matrix
Best Answer