Parzen window density estimation in MATLAB
Indentation is automatically fixed in MATLAB by marking everything, and do Ctrl+I.

The common practice is to have the first level alligned all the way to the left. Click here to see a screenshot from the builtin MATLAB function ind2sub. I have made no edits to it.



matrix is not a very good variable name. I suggest you choose something else. I don't have a suggestion off the top of my head, but there are probably more descriptive names.



[r c] = size(matrix);




There's not much more to say, best practice is to separate output values with commas.



The following subtracts the value of datapoint from A. I'm assuming datapoint is a scalar, not a matrix.

[r c] = size(matrix);
A = ones(r, c).*dataPoint;
sub = matrix - A;


This can be simplified a lot. If you want to subtract one value from all elements of a matrix in MATLAB, you can just do:

sub = matrix - dataPoint;


If dataPoint is a matrix, of the same dimensions as matrix, then you can do:

sub = matrix - dataPoint


Yes, that was exactly the same as above. As long as the dimensions match, or one of the variables is a scalar, you can simply subtract one from the other.



I guess dw means down? If so, call it down, it's easier to understand, and is not very hard to write.



You mix camelCase and lowercase. I suggest you stick to one, and do dataPoint and returnValue.



You forgot end in the end. It works without it, but it is supposed to be there. 




  Is it correct?


I don't know. I don't know what it's supposed to do. I guess the simplest way to check it is to compare it to your C# implementation.