Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
indexing surprise
Posted:
Aug 3, 2011 10:52 AM
|
|
Hello colleagues,
i'm now into debugging for some time (~ 1h) until i recognized that Matlab has a quite surprising way of creating new variables. And it goes something like this:
>> a ??? Undefined function or variable 'a'. >> idx_new = [ 1 ; 2 ; 3]; >> size(idx_new)
ans =
3 1
>> net.bt = ones(6,1); >> size(net.bt)
ans =
6 1
>> par.height = 10.5; >> par.height(net.bt(idx_new))
ans =
10.5000 10.5000 10.5000
And now the punchline:
>> a(idx_new) = par.height(net.bt(idx_new))
a =
10.5000 10.5000 10.5000
so although my righthand side is a column vector and my index to a is a column vector , the result in the new created a is a row vector.
There may be a good (almost very good reason) to do this, but for me it came unexpected...
Wishing a happy day, Andreas
|
|
|
|