Why i cannot copy elements of matrix a(1X10) into b(2X5) matrix?
2 views (last 30 days)
Show older comments
a
a =
1 2 3 4 5 6 7 8 9 10
>> b
b =
0 0 0 0 0
0 0 0 0 0
>> b(1,:)=a(0:4) ??? Subscript indices must either be real positive integers or logicals.
0 Comments
Answers (1)
Jan
on 22 Jul 2011
The error message is descriptive:
Subscript indices must either be real positive integers or logicals.
Using "0:4" is not "positive", because Matlab's indexing is 1-based:
b(1, :) = a(1:5)
0 Comments
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!