'For' loop conditions

2 ビュー (過去 30 日間)
Lev Mihailov
Lev Mihailov 2019 年 7 月 5 日
コメント済み: Geoff Hayes 2019 年 7 月 5 日
for chek= 1:length(d)-1
if c(chek)+20>20;
nmm=MM(c(chek):c(chek)-20,chek) ;
mn=MM((c(chek)-20:c(chek)),chek) ;
C{chek}=mn;
X{chek}=nmm;
else
c(chek)+20<20
mn=0 ;
nmm=0 ;
C{chek}=mn;
X{chek}=nmm;
end
end
Help please, I have a cycle, I work with 'c', I know that some of its values ​​= 0, first add the essence of the cycle 20 to 'c', then back.
The error is that X knocks out all zeros.
With the values ​​of 'C' everything is fine
  2 件のコメント
David Goodmanson
David Goodmanson 2019 年 7 月 5 日
Hi Lev,
abbreviating c(chek) as b, then
b:b-20 produces: 1×0 empty double row vector
and
b:-1:b-20
produces a vector of descending values.
Geoff Hayes
Geoff Hayes 2019 年 7 月 5 日
Lev - perhaps this
else
c(chek)+20<20
should read
elseif c(chek)+20<20
instead. Also, I'm not sure I understand why you subtract 20 from the following
nmm=MM(c(chek):c(chek)-20,chek) ;
mn=MM((c(chek)-20:c(chek)),chek) ;
Please clarify.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by