In its commercial form, MATLAB has been around for 33 years now. Especially in its earliest days, MATLAB implementers had a tendency to be as permissive as possible with respect to input validation. Over time, we realized that this philosophy wasn’t always the best one for users, and we started making some of the language rules tighter and more regular. One example was the introduction of error messages about invalid indices (noninteger, nonpositive, etc.). However, we couldn’t always tighten up the behavior as much as we liked. Sometimes that was because we discovered that too much user code was exploiting the original behavior. That is one of the reasons you continue to see this kind of behavior variation in some places.

Generally, it is very unlikely that MathWorks developers will describe publicly the internal implementation details related to undocumented behavior, so I recommend against putting any effort into it. Instead, I would advise users to only use integer-valued indices. Users can explicitly call round or floor or whatever to convert the output of the colon operator to be integer-valued.

]]>While on the topic of indexing in MATLAB, I’d like to ask for your comment on the behavior, where MATLAB allows non-integer indices in some cases, as discussed in this post: http://stackoverflow.com/questions/40455299/ . This has caused much confusion to many of us on SO, and some official explanation could really help.

Thanks! ]]>

One question, if i scale 1/2 by averaging pixels and plot the interpolation kernel, would it just be a pulse at +-1 with amplitude of 1?

Thanks. ]]>

Thanks you Steve! ]]>

Nice series on aliasing!

I think the key here is to understand that the two low-pass filters (interpolation filter of step 1 and blurring filter of step 2) have the same shape but different width. When multiplied in the Fourier domain, they lead to a single low-pass filter that is the narrower of the two (wider in the spatial domain). Thus, if filter #2 is wider, you use that one, otherwise you use #1. This is why you can simply make the interpolation filter wider when down-sampling, and don’t change anything when up-sampling.

]]>The reason is that you actually acquire the image in Fourier space; frequency sampling density corresponds to field-of-view. Insufficient sampling gives an image that’s too small, leading too aliasing.

]]>