Prev: technical help how to extract AVHRR NDVI values for points
Next: support vector machine number of features and samples
From: Marios Karaoulis on 10 May 2010 18:50 Hi, I have this problem k5=rand(10,10); index=[1 5 7]; I want to zero all elements in matrix k5, that are in line 1, 5 and 7. This is how I do it for i=1:3 for j=1:10 k5(index(i),j)=0; end end is there a way to avoid the double for loop, like using indexes? Thanks
From: ImageAnalyst on 10 May 2010 19:01 k5(index,:) = 0
From: Marios Karaoulis on 10 May 2010 19:09 On May 10, 5:01 pm, ImageAnalyst <imageanal...(a)mailinator.com> wrote: > k5(index,:) = 0 and if you have double indexes? k5=rand(10,10); index=[1 5 7]; index2=[2 4 6]' for i=1:3 for j=3 k5(index(i),index2(j))=0; end end
From: Roger Stafford on 10 May 2010 19:35 Marios Karaoulis <marios.karaoulis(a)gmail.com> wrote in message <852a0217-6000-4eb7-8084-67dd877f3d1f(a)j36g2000prj.googlegroups.com>... > On May 10, 5:01 pm, ImageAnalyst <imageanal...(a)mailinator.com> wrote: > > k5(index,:) = 0 > > and if you have double indexes? > k5=rand(10,10); > index=[1 5 7]; > index2=[2 4 6]' > > > for i=1:3 > for j=3 > k5(index(i),index2(j))=0; > end > end Then do k5(index,index2) = 0; Roger Stafford
From: Marios Karaoulis on 13 May 2010 17:46
I tried and succeed making some of my function more efficient. But I can't find a way to handle this function. I need to make some sums in a triple for loop. consider this. num_mes=43; num_param=104; % pa and pm are a INTEGER matrices dimension 1Xnum_mes pa=[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,9;]; pm=[3,4,5,6,7,4,5,6,7,8,1,5,6,7,8,9,1,2,6,7,8,9,1,2,3,7,8,9,2,3,4,8,9,3,4,5,9,4,5,6,5,6,7;]; % icon is a INTEGER matrix in 3X2470 dimensions icon=randi([1 1303],3,2470); %aaa is a float matrix with 10X1303 dimensions aaa=rand([10,1303]); %x_flux y_flux is a float matrix with 10X2470 dimensions x_flux=rand([10,2470]); y_flux=rand([10,2470]); %width_param is a INTEGER mX1 matrix, that shows how many times the %internal loop must be calculated. width_param=randi([1 50],num_param,1); for mes=1:num_mes for m=1:num_param for k=1:width_param(m) l=param(m,k); a1=icon(1,l); a2=icon(2,l); a3=icon(3,l); area=area_elm(l); i=pa(mes); j=pm(mes); s1=aaa(i,a1)+aaa(i,a2)+aaa(i,a3); s2=aaa(j,a1)+aaa(j,a2)+aaa(j,a3); sum=2*(aaa(i,a1)*aaa(j,a1)+aaa(i,a2)*aaa(j,a2)+aaa(i,a3)*aaa(j,a3))+s1*s2; sum=area*sum*k_absc(kit)*k_absc(kit)/(12*prop(l)*prop(l)); jam=x_flux(i,l)*x_flux(j,l)+y_flux(i,l)*y_flux(j,l)+sum; jactmp=jactmp+jam; end trans_jac2(mes,m)=jactmp; jactmp=0; end end Any ideas? |