Re: Problem in generating a DO cycle (mathematica 6.0)
- To: mathgroup at smc.vnet.net
- Subject: [mg95353] Re: Problem in generating a DO cycle (mathematica 6.0)
- From: dh <dh at metrohm.com>
- Date: Fri, 16 Jan 2009 06:10:02 -0500 (EST)
- References: <gkn5jk$ihb$1@smc.vnet.net>
Hi Valeria,
if I understand correctly, you have a matrix: m and want to change this
into a vector: v, containing the elemnsts of m. In mathematica there are
often easier ways than Do loops. In this case:
Flatten[m]
will return a vector containing the elements of m raw-wise (first
raw,second raw..)
Flatten[Transpose[m]]]
gives a vector column-wise.
hope this helps, Daniel
Valeria Volpe wrote:
> Dear all I have a problem in generating a DO cycle (mathematica 6.0).
>
> Through these commands I acquire a bitmap image from a my folder and create
> a "Graylevels" file:
>
> Quit;
> SetDirectory[ "C:\\Users\\...\\Dati\\\Bitmap\\\xxx"];
> nome = "p6a.bmp";
> Import[nome, "ImageSize"];
> row = ToExpression[Import[nome, "ImageSize"]][[1]];
> col = ToExpression[Import[nome, "ImageSize"]][[2]];
> vmax = row*col;
> gv = Array[f, vmax];
> gl = Import[nome, "GrayLevels"];
>
>
> at this point I have a matrix with all graylevels.
>
> Now my problem is to create a two DO cycle (one for rows and one for
> columns) which allow me to generate an array (gv) whose elements are the
> product row x column of the matrix:
>
> gv[i] = gl [j,k]
>
> where:
> {i,1,Vmax}
> {j,1,row}
> {k,1,col}
>
> Can you pleasa herlp me to generate these Do Cycle?
>
> Thanky
> Vale
>
>