What does "IND" do?

127 ビュー (過去 30 日間)
Alice Marin
Alice Marin 2020 年 7 月 8 日
コメント済み: Alice Marin 2020 年 7 月 8 日
Could someone please explain what is the meaning behind the following sequences? I don't quite understand the meaning of the "ind" function.
Thank you!
P.S. I don't know whether it is worth mentioning, but the code was written using Octave.
-------------------------
indBl=[];
%
if (Blt(1) == 1)
indBl=[indBl 1];
end
if (Blr(1) == 1)
indBl=[indBl 2];
end
%
if (Blt(2) == 1)
indBl=[indBl 2*NE1+1];
end
if (Blr(2) == 1)
indBl=[indBl 2*NE1+2];
end
%
if (Blt(3) == 1)
indBl=[indBl 2*NE+1];
end
if (Blr(3) == 1)
indBl=[indBl 2*NE+2];
end

採用された回答

Walter Roberson
Walter Roberson 2020 年 7 月 8 日
There is no "ind" function in that code.
What the code is doing is adding values to the end of a list.
If Blt(1) is 1, then add 1 to the end of the list.
Then if Blr(1) is 1, add 2 to the end of the list (that might have been updated in the previous step.)
Then if Blt(2) is 1, add 2*NE1+1 to the end of the list.
And so on.
The [] is the same as horzcat() for this purpose, so you could write it as
if Blt(1) == 1
indBl = horzcat(indBl, 1);
end
You could also write it as
if Blt(1) == 1
indBl(end+1) = 1;
end
  1 件のコメント
Alice Marin
Alice Marin 2020 年 7 月 8 日
Thank you for the clarification!

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by