# How to store many variables of type AffineMap?

**URL:** <https://discourse.julialang.org/t/how-to-store-many-variables-of-type-affinemap/30016>\
**Category:** General Usage\
**Tags:** images, arrays\
**Created:** [October 17, 2019, 9:23am UTC](https://discourse.julialang.org/t/how-to-store-many-variables-of-type-affinemap/30016 "2019-10-17T09:23:06Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [October 18, 2019, 6:15am UTC](https://discourse.julialang.org/t/how-to-store-many-variables-of-type-affinemap/30016/3 "2019-10-18T06:15:37Z")

</div>

> [@nilshg](#):
>
> ```julia
> tfm_array = [AffineMap([0 0; 0 0], [0, 0]) for _ in 1:5]
> 
> ```

Thank you, that did the trick.  
Interestingly, I now also see something similar in the updated version of [“Julia by example”](https://discourse.julialang.org/t/is-julia-by-example-tutorial-totally-abandoned/25086/4). Seems I have missed this before.

For others trying to replicate @nilshg’s solution: Make sure the first command is `using CoordinateTransformations`. CoordianteTransforms doesn’t seem to exist at all.

EDIT:

I meanwhile figured that there is a problem in this solution: The types are wrong.  
The above solution generates an AffineMap with type `Int64`. However, we need  
`AffineMap{RotMatrix{2,Float64,4},StaticArrays.SArray{Tuple{2},Float64,1,2}}`. If I want to assign a variable of this type to the Int64-type array, I get a “cannot convert”-error.

My current workaround is to call the registering command from my previous thread once, thereby generating the correct type for the AffineMap (stored in a variable called `tfm`). I then modified the above solution to this: `tfm_array = [tfm for _ in 1:size(inputimg,3)]`. This generates an array of the correct type. I then loop through my stack and fill the array.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-store-many-variables-of-type-affinemap/30016)._
