Reputation: 863
I'm looking at a rather large and poorly written Matlab program. One of the things that makes understanding the code tricky is the variables don't show their type. In searching I only found explanations how to do this while debugging code(the whos and class commands). I'm looking for a way to view type information in the editor itself.
For example in the following code I would like to know the type of A and B:
classdef Data
properties
B;
function obj = Data(A)
obj.B = A.B;
end
Or is the type not determined until the function is called, and A could be any class with a B parameter?
Upvotes: 3
Views: 288
Reputation: 12214
As I mentioned in the comments, unfortunately there isn't any way I know of to do this in the IDE without entering the debugger because MATLAB is not statically typed. You can also trace through the function and see what is calling the methods/functions/etc. in question and the variables used.
Your ending sentence is correct. Looking at your example solely in the eyes of the IDE A
could be any data type, even one where the dot notation isn't valid (and thus would throw an error). It's up to the user to add input validation for functions that are not built in.
Upvotes: 2
Reputation: 509
Usually numeric variables are defined as doubles, you can ask if a variable belongs or not to a specific data type, here are some ways to do it.
Upvotes: 1