Can you pls explain me the for loop here,how is it working and how is this code working >>[~, indx] = find(wd >= wd(1)*0.7)
Show older comments
function height = getHeight(signal)
maxVal = max(signal);
wd = [];
for nn = 1 : maxVal
wd(nn) = getSignalWidth(signal, nn);
end
[~, indx] = find(wd >= wd(1)*0.7);
height = indx(end);
5 Comments
Sivakumaran Chandrasekaran
on 13 Jan 2016
wd(1).. first element is selected ............... wd(1)*0.7............find(wd > ans).. find how many numbers are greater than earlier answer.
check find command with a simple example separately. then solve this problem
Akhi shah
on 13 Jan 2016
Walter Roberson
on 13 Jan 2016
find() can return multiple outputs. Using it in the two-output form would normally be written as
[somevariable, indx] = find(wc >= wd(1)*0.7);
If you do not need the first result, here named "somevariable", then you can instruct MATLAB to throw the result away by not giving a variable name and instead using ~ . So
[~, indx] = find(wd >= wd(1)*0.7)
is the same as
[somevariable, indx] = find(wc >= wd(1)*0.7);
clear somevariable
Except that, since in this case wd is a vector, there is absolutely no point in using the two outputs form of find. The code is exactly identical to
indx = find(wd >= wd(1)*0.7);
Akhi shah
on 13 Jan 2016
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!