Re: Conditions
- To: mathgroup at smc.vnet.net
- Subject: [mg29246] Re: Conditions
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 8 Jun 2001 04:15:33 -0400 (EDT)
- References: <9fna8p$bih$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Yannis, We can create a function which carries out your instructions for each row and map it over the rows of m. m={{1,2,0,3,4},{1,2,3,4,5}}; If[FreeQ[#,0], Last[#], 0]&/@m {0,5} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 <Yannis.Paraskevopoulos at ubsw.com> wrote in message news:9fna8p$bih$1 at smc.vnet.net... > Hi again, > > I've been puzzled by the following problem which I have to admit it's > not complicated but yet... > > 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. > > Its obvious to me that I do something stupid but I can't figure it out. > Any help would be very much appreciated. > > Best regards > > > yannis > > > Visit our website at http://www.ubswarburg.com > > This message contains confidential information and is intended only > for the individual named. If you are not the named addressee you > should not disseminate, distribute or copy this e-mail. Please > notify the sender immediately by e-mail if you have received this > e-mail by mistake and delete this e-mail from your system. > > E-mail transmission cannot be guaranteed to be secure or error-free > as information could be intercepted, corrupted, lost, destroyed, > arrive late or incomplete, or contain viruses. The sender therefore > does not accept liability for any errors or omissions in the contents > of this message which arise as a result of e-mail transmission. If > verification is required please request a hard-copy version. This > message is provided for informational purposes and should not be > construed as a solicitation or offer to buy or sell any securities or > related financial instruments. > >