Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
matlab の配列で最初のゼロ要素を見つけたいです。「検索」機能を使用してゼロを見つけていますが、正しい答えは得られませんでしたが、1の正しい答えが得られました。
find次のように使用すると、トリックを実行する必要があります。
find
> a = [1 2 3 0 5 6 0 8 9]; > find(a==0, 1, 'first') ans = 4
これが機能しない場合 (および問題に関する追加の詳細情報) をお知らせください。
MATLAB 検索
>> a = [1 2 3 0 5 6 0 8 9]; >> a=a==0; >> n=1:length(a); >> [n out]=max(a./n); out = 4