Re: Conditions
- To: mathgroup at smc.vnet.net
- Subject: [mg29247] Re: Conditions
- From: BobHanlon at aol.com
- Date: Fri, 8 Jun 2001 04:15:34 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2001/6/7 1:28:18 AM, Yannis.Paraskevopoulos at ubsw.com
writes:
>assume that we have a matrix m with dimensions (RxC) then create a
>vector v, which has value 0 when there is a zero at any point across
>m's row. Otherwise v's value would be equal to the last value of the
>corresponding m row.
>
>
>I tried for example:
>
>
>I initiated a vector v={a,b}. I had to that as
>
>Table[If[m[[i,j]]==0,v[[i]]=0,v[[i]]=g[[i,5]]],{i,2},{j,5}];
>v
>
>Out:= {1,1} when I expected {0,1}
>
>I also tried
>
>v:=0 /; g/.x_:>x==0
>v:=Table[g[[i,5]],{i,2}]
>
>with same results.
>
Assuming that I understood your intent, then
v = (If[FreeQ[#,0],Last[#],0]&/@m)
Bob Hanlon
Chantilly, VA USA