|
Prev: Problem with digits in an image name -Eg:img000111.png
Next: problem on how to callback multiple *.m files from a single
From: Dave on 18 Jul 2010 13:56 Dear Matlab Gurus, Is there an easier way to assign a vector to a vector element? I currently have to pre-declare a matrix e.g. A=zeros(10,3); A(:,1)=data(:); when really I would simply like to do A(1)=data; where data is a vector of values
From: dpb on 18 Jul 2010 14:36 Dave wrote: > Dear Matlab Gurus, > > Is there an easier way to assign a vector to a vector element? > > I currently have to pre-declare a matrix e.g. > > A=zeros(10,3); > > A(:,1)=data(:); > > when really I would simply like to do > > A(1)=data; > > where data is a vector of values Only if you wish A(1) to refer to a cell array; otherwise the sizes have to be conformant on both rhs and lhs. In an array or matrix, A(1) refers to only a single element; can't be interpreted as anything else or it would break any reference in looping constructs, etc., etc., etc., ... To somehow have some other sort of non-orthogonal interpretation in assignment statements only would be _a_bad_thing_ (tm) from that standpoint only even if could figure out a non-ambiguous set of syntax rules. -- --
From: Dave on 18 Jul 2010 16:14
"Dave " <Davefulton(a)rocketmail.com> wrote in message <i1vf7j$2bo$1(a)fred.mathworks.com>... > Dear Matlab Gurus, > > Is there an easier way to assign a vector to a vector element? > > I currently have to pre-declare a matrix e.g. > > A=zeros(10,3); > > A(:,1)=data(:); > > when really I would simply like to do > > A(1)=data; > > where data is a vector of values Thank you. |