Buildind special vector? V(3)=V(6)=V(9)...=0

3 次查看(过去 30 天)
How can I build
V=[1 1 0 1 1 0 1 1 0 1 1 0....]vector.I want to put N value and it will reply me V vector..
Elements fo V will be V(3)=V(6)=V(9)...=0

采纳的回答

Jan
Jan 2013-3-6
编辑:Jan 2013-3-6
Another guess:
V = ones(1, N);
V(3:3:end) = 0;

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-3-6
编辑:Azzi Abdelmalek 2013-3-6
V=[1 1 0 1 1 0 1 1 0 1 1 0]
N=3
V(N:N:end)=0

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by