How do i create a matrix of size 1 row and 1501 column, with values [1 -1 1 -1 1 -1.... etc
3 次查看(过去 30 天)
显示 更早的评论
回答(3 个)
Wayne King
2012-5-1
One way:
x = ones(1,1501);
x(2:2:end) = -1*x(2:2:end);
Another way
y = repmat([1 -1],1,751);
y(end) = [];
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!