Filter löschen
Filter löschen

How to make this?

1 Ansicht (letzte 30 Tage)
Gemalyn Apostol
Gemalyn Apostol am 25 Okt. 2016
Beantwortet: KSSV am 25 Okt. 2016
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?

Akzeptierte Antwort

KSSV
KSSV am 25 Okt. 2016
z = ones(1,10);
a = [3 8] ;
b = [5 9] ;
for i = 1:length(a)
z(a(i):b(i)) = 0 ;
end

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by