function [ x, y ] = rok_room_cell_to_xy (room, i)
    % [ x, y ] = ROK_ROOM_CELL_TO_XY (config, i)
    %
    % Converts the cell index i to the coordinates of the corresponding
    % cell.
    %
    % Input:
    %  - room = room configuration structure, obtained by ROK_ROOM_CREATE()
    %  - i = 1xN array of cell indices to convert
    %
    % Output:
    %  - x = 1xN array of x coordinates (if *single* output is requested,
    %    tnen x is 2xN array containing both x and y coordinates)
    %  - y = 1xN array of y coordinates
    %
    % See also: ROK_ROOM_XY_TO_CELL, ROK_ROOM_CREATE
    %
    % Copyright (C) 2011-2012, Rok Mandeljc <rok.mandeljc@fe.uni-lj.si>

    [ xi, yi ] = ind2sub([ room.nx, room.ny ], i);
    x = room.xVals(xi);
    y = room.yVals(yi);
    
    % If single output, combine both coordinates into a single array
    if nargout < 2,
        x = [ x; y ];
    end
end