using sed command to display contents where line numbers are stored in variables

if i want to display the contents of a file between say line number 3 and 10 then i use the following command

sed -n '3,10p' filename

if this 3 was contained in x and 10 was contained in y then how wud this command modified?

sed -n '$x,$yp' filename does not work..please advise

Look at these 2 posts

sed -n "$x,${y}p"