Re: sorting and sum vector
- From: "Yi Cao" <y.cao@xxxxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 17:02:02 +0000 (UTC)
"Par Hjalmarsson" <par.hjalmarsson@xxxxxxxxx> wrote in
message <fsqh99$mh3$1@xxxxxxxxxxxxxxxxxx>...
"Yi Cao" <y.cao@xxxxxxxxxxxxxxx> wrote in message <fsqgf2is
$mur$1@xxxxxxxxxxxxxxxxxx>...
"Par Hjalmarsson" <par.hjalmarsson@xxxxxxxxx> wrote inup.
message <fsqfiu$4dc$1@xxxxxxxxxxxxxxxxxx>...
Hi,
I have a sorting and sum problem that I need to speed
meHopefully there might be someone here that could help
do
this.
The code:
x=length(output2); %output2 is a Nx6 Matrix where N
amua*
value between 900000 and 5000000
xx=fix(((sqrt(output2(:,3).*output2(:,3)+output2
(:,4).*output2(:,4))/0.005))/mus)+1;
new_out=zeros(5000,1);
for j=1:x
new_out(xx(j))=new_out(xx(j))+output2(j,1)*exp(-
here.(output2(j,2)-output2(j,64))/mus);
end
Both mua and mus are constants.
/Par
You said output2 is Nx6, but you used output2(j,64)
It is not correct.
Yi
Sorry should be output2(j,6)
Par
You may wish to use accumarray to replace your loop.
Something like (I have not tested it)
new_out=accumarray(xx,output2(:,1).*exp(-mua*(output2(:,2)-
output2(:,6))/mus));
hth.
Yi
.
- References:
- sorting and sum vector
- From: Par Hjalmarsson
- Re: sorting and sum vector
- From: Yi Cao
- Re: sorting and sum vector
- From: Par Hjalmarsson
- sorting and sum vector
- Prev by Date: Re: image overlay
- Next by Date: Re: Error while executing compiled code on linux
- Previous by thread: Re: sorting and sum vector
- Next by thread: poly2trellis function
- Index(es):
Relevant Pages
|