i want to generate a sequence of n numbers
396 次查看(过去 30 天)
显示 更早的评论
How would i generate a secuence of N amount of numbers starting at -4 and going up in steps of 2?
Cheers
3 个评论
Robert U
2020-3-9
Those sequences work with variables as end values as demonstrated in the answer by Benni.
采纳的回答
Benjamin Großmann
2020-3-9
编辑:Benjamin Großmann
2020-3-9
You can create sequences with the colon operator (:), for exapmle
v = [4:2:100];
creates v = [4, 6, 8, ... , 100] with values starting at 4, an increment of 2 and stop value 100.
For N numbers starting at -4 and an increment of 2, you have to calculate the stop value:
N = 10;
start_val = -4;
inc = 2;
stop_val = (N-1)*inc + start_val;
v = [start_val:inc:stop_val];
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!