In a column how do I find the first cell to equal 0?
古いコメントを表示
I have this code so far:
for i = 7:length(mydata)
index = find (mydata{i,1}(:,5))== 0
end
However, this returns all the zeros in the whole matrix, I require a cell reference in column 5 as to when the first 0 occurs.
4 件のコメント
Azzi Abdelmalek
2014 年 4 月 24 日
This is not clear
Franchesca
2014 年 4 月 24 日
Franchesca
2014 年 4 月 24 日
Christopher Pedersen
2014 年 4 月 24 日
編集済み: Christopher Pedersen
2014 年 4 月 24 日
Finding the first zero: you can use additional inputs to "find", to only return the first value found:
loc = find(x==0,1,'first') returns the 1 first times x==0
or loc = find(x==0); loc = loc(1); returns all the occurences of zero, then extracts the first.
Extracting values up to the first zero: y = x(1:loc);
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!