From: Matt J on 18 Jan 2010 07:37 "Steve Amphlett" <Firstname.Lastname(a)Where-I-Work.com> wrote in message <hj1asc$h12$1(a)fred.mathworks.com>... > > Sadly, ML doesn't support zero-based indexing. x(0,:) isn't allowed. What a shame. Although, I do show how you can construct a zero-based indexable array here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/266512#696653
From: Steve Amphlett on 18 Jan 2010 08:51 "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hj1e1j$8vb$1(a)fred.mathworks.com>... > "Steve Amphlett" > > > I have a rather simple matlab script that I am recieving the following error on: > > > Subscript indices must either be real positive integers or logicals. > > > > > > size = 10; > > > x = zeros(size,6); > > > for i = 0:size > > > x(i,:) = [i (i +1) (i +2) (i + 3) (i + 4) (i + 5) ]; > > > end > > > > > > I know the reason I aym recieving the error is because I am using i in the index of the x matrix, but it seems like i should be able to do this.... Does anyone know of a way the index a given row in a for loop like that? > > > > > > Sadly, ML doesn't support zero-based indexing. x(0,:) isn't allowed. What a shame. > Steve, > why it's a shame? (I use just Matlab and T-SQL so i can't find any good reason to be asham for :)) > Oleg It's a well trodden debate, not worth bringing up yet again. The CSSM archives are full of it. I've put up with it for 20+ years now, but still get bitten when people hand me ML prototypes to convert into real code.
From: Matt J on 18 Jan 2010 09:32 "Steve Amphlett" <Firstname.Lastname(a)Where-I-Work.com> wrote in message <hj1p07$kva$1(a)fred.mathworks.com>... > It's a well trodden debate, not worth bringing up yet again. The CSSM archives are full of it. I've put up with it for 20+ years now, but still get bitten when people hand me ML prototypes to convert into real code. ================= I think even with zero-based indexing, you have bigger hassles making that conversion: the absence of for-loops, the preponderance of unnecessary logical masks, etc...
From: Steve Amphlett on 18 Jan 2010 09:54 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hj1rd2$qn1$1(a)fred.mathworks.com>... > "Steve Amphlett" <Firstname.Lastname(a)Where-I-Work.com> wrote in message <hj1p07$kva$1(a)fred.mathworks.com>... > > > It's a well trodden debate, not worth bringing up yet again. The CSSM archives are full of it. I've put up with it for 20+ years now, but still get bitten when people hand me ML prototypes to convert into real code. > ================= > > I think even with zero-based indexing, you have bigger hassles making that conversion: the absence of for-loops, the preponderance of unnecessary logical masks, etc... A moot point now. I spent a few days upgrading my C++ Matrix class to be either zero or one based. So ML code can be folded in line by line.
From: Jan Simon on 18 Jan 2010 12:17 Dear Oleg! > > x(i,:) = [i (i +1) (i +2) (i + 3) (i + 4) (i + 5) ]; > Third: 'i (i +1)' is not a valid expression in matlab. If you're trying to multiply, use the *. BTW: '[i (i + 1)]' is valid because there is a space between "i" and "(". It is equivalent to: [i, i + 1] I personally avoid vector notations with omitted separators, because they are susceptible for bugs. Compare: [i i] [i i + 1] [i i +1 ] % no space between + and 1 [i i+ 1] [i i+1] An even better: [i i... +1] % to be true: I'm not sure if this is [1x2] or [1 x 3] vector! [1 2] [1 ... 2] [1, ... 2] Some of these notations procude different results when parsed by Matlab 5.3 - but I forgot which one. It found this so scary, that I decided to insert commas and semicolons whenever it is allowed. Have fun, Jan
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Mean Shift Clustering Matlab code Next: Compiler 32 or 64 bit build options? |