Re: question about matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg63846] Re: [mg63832] question about matrix
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 19 Jan 2006 00:02:42 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
m={{a[1,1],0,a[1,3],0,a[1,5]},
{a[2,1],0,a[2,3],0,a[2,5]},
{a[3,1],0,a[3,3],0,a[3,5]},
{0,0,0,0,0},
{a[5,1],0,a[5,3],0,a[5,5]}};
fm=Transpose[Select[Transpose[
Select[m,Union[#]!={0}&]],
Union[#]!={0}&]]
{{a[1, 1], a[1, 3], a[1, 5]}, {a[2, 1], a[2, 3],
a[2, 5]}, {a[3, 1], a[3, 3], a[3, 5]},
{a[5, 1], a[5, 3], a[5, 5]}}
fm==Transpose[DeleteCases[Transpose[
DeleteCases[m,{(0)..}]],{(0)..}]]
True
fm==Transpose[Transpose[m/.
{(0)..}:>Sequence[]]/.
{(0)..}:>Sequence[]]
True
Bob Hanlon
>
> From: "Tun Myint Aung" <tma at nus.edu.sg>
To: mathgroup at smc.vnet.net
> Subject: [mg63846] [mg63832] question about matrix
>
>
> Dear Mathgroup,
>
> I have a matrix and it may have rows and columns which are zeros. I
> can drop the rows and columns manually but it is troublesome. So my
> question is that how to drop the rows and columns that are zeros
> automatically.
>
> Best Regards,
>
> Tun Myint Aung
> Graduate Student
> National University of Singapore
> E1A #02-18
> Kent Ridge, 119260, Singapore
> E-mail g0202015 at nus.edu.sg <mailto:g0202015 at nus.edu.sg>
>
>
>
>
>