What you get with: (0:n-1)*n + 1:n
Show older comments
What you get with:
n = 4;
(0:n-1)*n + 1:n % 1 2 3 4
I was expecting:
(0:n-1)*n + (1:n) % 1 6 11 16
Accepted Answer
More Answers (3)
Sean de Wolski
on 12 Apr 2011
And the transpose acts as expected:
>> ((0:n-1)*n)'
ans =
0
4
8
12
>> ans+(1:n)'
ans =
1
6
11
16
1 Comment
Oleg Komarov
on 12 Apr 2011
Sean de Wolski
on 12 Apr 2011
I'm able to replicate this. Mac OSX R2009b.
It also fails if I break it between lines:
>> ((0:n-1)*n)
ans =
0 4 8 12
>> ans+1:n
ans =
1 2 3 4
VIGNESH
on 30 Apr 2023
0 votes
u = 0:1/n:1
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!