function [Id_filtered, Iq_filtered] = matrix_1d_filter(Id,Iq,windowSize)
%
%    Copyright (c) 2014 by Plexim GmbH All rights reserved.
%
%    A free license is granted to anyone to use this software for any legal
%    non safety-critical purpose, including commercial applications,
%    provided that: 1) IT IS NOT USED TO DIRECTLY OR INDIRECTLY COMPETE
%    WITH PLEXIM, and 2) THIS COPYRIGHT NOTICE IS PRESERVED in its
%    entirety.
%
%    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
%    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
%    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
%    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
%    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
%    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
%    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
% This function takes as inputs square matrices Id and Iq. It then uses a
% moving average filter along the columns of Iq and the rows of Id. The
% windowSize input controls the size of the averaging window. If an even
% integer is selected then the parameter is incremented by 1 to make it odd.
%
% The output of this function is a filterd version of Id and Iq.
%
% Inputs:
%
% (Id, Iq): look-up tables for (d-axis, q-axis) currents. It is assumed
% that each row corresponds to a unique value of flux linkage in the d-axis
% and each column corresponds to a unique value of flux linkage in the
% q-axis.
%
% windowSize: Corresponds to the averaging length of the averaging vector.
% A windowSize of 3 will create an averaging vector that averages three
% consecutive entries. Must be an odd integer. If an even integer is used
% then it is incremented by 1 to make it odd.
%
% WARNING: Chosing a large windowSize will cause significant deviation from
% the original data. A windowSize of 3,5,7 or 9 is recommended.
%
% Plexim, Inc.
% Author: Munadir A. Ahmed
% Date: 07/17/2014