How to handle expansion of wood when attaching a bed to the walls of a room
Wood expansion is mostly an issue across the grain, and can almost always be ignored when considering movement with the grain (your 2m dimension). See this post on woodworking for some more details. 

Assuming you're using 1x4 material as in the linked question, and assuming you get plain-sawn stock and not quarter-sawn, the most movement will be along the 4" (well, actually 3.5") direction - swelling to e.g. 3.75" and shrinking to 3.25"* . You may see some slight movement along the 1" (actual 3/4") direction, but that might swell to e.g., 25/32" and shrink to 23/32"* . 

Note that if you air condition the space, the actual movement will be much less than if the space were not conditioned, or if the piece were outside.



*These numbers are examples and may not be indicative of actual movement.