We create a vector z = ones(1,10);and define some intervals of z to be zero. The intervals are stored in vectors a and b where a contains the start indices and b the end indices of the intervals. With a = [3 8] and b = [5 9] the desired result should be r = [1 1 0 0 0 1 1 0 0 1].How do we make this?

 採用された回答

KSSV
KSSV 2016 年 10 月 25 日

0 投票

z = ones(1,10);
a = [3 8] ;
b = [5 9] ;
for i = 1:length(a)
z(a(i):b(i)) = 0 ;
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2016 年 10 月 25 日

回答済み:

2016 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by