- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Tentatively I tried to update the second and third component in a integer vector with dimensions a(100,1,1):
a(5,1:1,1:1)=[2,3]
but the compiler discover that the two vectors had different shapes. How should this vector update be written?
Best regards
Anders S
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The left-hand side is a single element of the array a, whereas the right-hand side is an array with two elements. The compiler is quite right here. I do not quite understand which elements of the array a you mean, but this should work:
a(2:3,1:1,1:1) = [2,3]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use: a(2:3,1,1) = [2,3] ! Where array a has dimension (100,1,1)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody,
Thanks for your answers that made me think twice. It is embarassing to confess that I should define a as a vector a(100,2). Then
a(5,1:2)=[2,3] works fine!
Sorry to have taken your time! Vector usage apparently is not basic to everybody.
Best regards
Anders S

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page