How to make this?

1 次查看(过去 30 天)
Gemalyn Apostol
Gemalyn Apostol 2016-10-25
回答: KSSV 2016-10-25
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
z = ones(1,10);
a = [3 8] ;
b = [5 9] ;
for i = 1:length(a)
z(a(i):b(i)) = 0 ;
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by