Hi
I have a 2D matrix, and I like to eliminate rows whose last column elements are zeros. Anyone could give me a quick hand (or a function)?
Xiaxing (a Mathematica beginner)
Not too hard:
Flatten[MapThread[ConstantArray, {{a, b, c, d, e}, {2, 3, 1, 2, 3}}]] {a, a, b, b, b, c, d, d, e, e, e}
Hi Xiaxing,
Maybe this?
SeedRandom[12]; matrix = RandomInteger[2, {5, 5}] (* {{0, 2, 1, 0, 0}, {0, 2, 2, 2, 0}, {1, 2, 1, 1, 0}, {0, 1, 2, 2, 2}, {1, 0, 0, 2, 1}} *) matrix // Select[Last@# != 0 &] (* {{0, 1, 2, 2, 2}, {1, 0, 0, 2, 1}} *)
Hi Rohit and others What about when one wants to use three 2 X 2 matrices in the computation as inputs to get three 3 X 3 matrices as output ? I am expecting as one of the output a 3 X 3 matrix {{0, 0, 0}, {0, 2, 0}, {0, 0, -2}} . The computation is correct, however, to achieve the 3 X 3 is challenging. See attachment.
Is there a reason for using Graphics? Example using ListPlot.
Graphics
ListPlot
points = {{1, 1}, {2, 2}, {3, 3}, {3, 4}} // Map[List]; pointSizes = {1.1, 3.2, 2, 4}; ListPlot[points, PlotStyle -> PointSize /@ (pointSizes/100)]
Since this question is unrelated to the original question, it should have been a new post.
Hi Again
I like to plot a hundreds of points with different sizes: example points locations pts= {{1,1},{2,2},{3,3}, {3,4},....}, with sizes ptsize={1.1, 3.2, 2, 4, ...} I'm try to use: Graphics[{Black, PointSize[#], Point[pts]]
How should I do with the PointSize? Any quick helps?
Great thanks
It worked perfectly. Thanks
If I like to turn {{a, b, c, d, e}, {2, 3, 1, 2, 3}}
into {{a, a, b,b,b, c, d,d,e, e,e},
Meaning repeat the number of elements per numbers in the 2nd row.
Any quick helps?
Xiaxing (a Mathematica beginner) Great thanks.
Also if Matrix {{a,b,c,d,e},{2,3,1,2,3}} needs to turn to {{a,a,b,b,b,c,d,d,e,e,e}}meaning to repeat the elements the number of the 2nd row indicate.
Anyone can give me a quick help?
Thanks
It worked. Great thanks
Xiaxing