What is a grandfathered syntax, as in the MATLAB "radon" function?
Asked Answered
P

1

5

I found a function with a "secret" input, which someone can perhaps explain? What could be the reason? Are there many cases of such a thing?

In the documented syntax of radon function, there are two ways to call the function - the conventional one with inputs of I and THETA, (for image and desired projection angles), and also an option to omit THETA, and give only I as input.

But in the comments inside the radon.m file, there is another part at the end, that is described as "grandfathered syntax". This allows three inputs, including also the number of desired projections. And, it really works!

So, why isn't this documented? Has it been available in the past, and then deleted/changed (as "grandfathered syntax" would suggest)? So why does this still work?

And, another question about radon.m:

The main part of the function is computed by calling another function, called radonc. What is it? Where does it reside? I can't find it, or any mention of it anywhere.

Peggypegma answered 2/9, 2013 at 10:5 Comment(3)
My guess is that they removed it from the documentation to "strongly encourage" people to use the new syntax. It still works for backwards compatibility -- so that code written in older MATLAB versions still works in newer MATLAB versions. This process is very common; it's called depracation. This is the MathWorks' take on it.Twana
As for your second question (again, guessing here) -- whenever some function name ends in "c", it usually indicates that it has been implemented in C and then compiled to a MEX file, usuallty to speed up the execution of some portion of the function.Twana
@RodyOldenhuis Thanks. About the MEX file- how can my machine run the file, if it doesn't have the file itself? Or i just didn't find it...?!Peggypegma
L
10

"Grandfathered" syntax typically means that it's a syntax that

  1. used to be documented and supported
  2. still needs to be kind of supported because some customers still rely on it, and MathWorks wouldn't want their code to break
  3. is no longer recommended, and is therefore undocumented so that new users will not start to rely on it
  4. may get completely removed in future.

radonc is in \toolbox\images\images\private. The which command won't find it because it's in that private directory, and so can only be called by functions in the directory immediately above (which includes radon itself). The file is radonc.mexw64 (possibly a different mex file extension if you're on a different platform to me), indicating that it's implemented as compiled C code rather than MATLAB code (and in case this is why you're asking, it means you can't see the source).

Edit: Note that in the same directory there is also a file radonc.m. This file doesn't do anything, as the mex file has higher precedence; it is there to provide help for the radonc function. If you type help radonc, you'll see that it shows the help text provided by the comments of radonc.m.

Leahy answered 2/9, 2013 at 10:22 Comment(4)
I've tried all of this, but in my version (R2008a) it says: "radonc not found". Anyway, thanks for the explained answer :)Peggypegma
As explained, if you try to execute radonc, or if you type which radonc, MATLAB will not find it. This is because it's in a private directory, and therefore not on the path - it can only be called from functions in the directory immediately above, which includes the radon function. Nevertheless, it is there. (Note, I don't have 8a available, but I believe everything I've said is true for that version).Leahy
I also believe all your explanations are true. What I wrote was only as regards to the "help radonc", and what my matlab answered me...Peggypegma
Try which -all radonc. MATLAB will find it if you have Image processing toolbox installed :)Drawstring

© 2022 - 2024 — McMap. All rights reserved.