overloading every function operator for a class in matlab -


I am creating a square, which is quite complex for all practical purposes (though it looks like what it looks like), ho Thought as a matlab real number.

In the class, I can surcharge a large number of matlab operators like Plus, Amver, etc.

This is probably impossible, but how would I go about overloading any of my classes? In other words, suppose I have an arbitrary task that takes the actual numbers and outputs the real numbers, and X says that my class is an example. I would like f (x) to correctly interpret the matlab (matbab), (I have a natural way of taking a function pointer and implementing it in my class, which I will do in the code). / P>

As issues, I can see them: There is no way of seeing matlab that a function takes the form of the actual number F as the input but I want that user to have my function

Do not I think anybody?

I do not think it is possible, but if it was, then it would be horrible.

ps: I know that maybe it can be found around by making a method which carries a fun car in the form of input, but it is less beautiful ..

Thank you! < / P>

Edit:

Sorry, I know that this is a bit confusing I'll be more clear I have included one such group which represents random, real variables (say on a discrete set of simplicity). Possibility of random variables in my class distribution, as well as its potential value.

For any two random variable X, Y, the Yoga X + Y is well defined, so if I have X and X Y which represent the random variable, it would be good if Z = X + Y defines a new random variable equal to the amount of X and Y with the proper set and distribution. I did this, overloading the plus operator. This is good.

Say that I have an arbitrary function f, say "cos". Well, there is also a random variable for any random variable x, cos (x), and it would be nice if i can just type z = cos (x), which will automatically create an example of my square, justified The domain will calculate and the probability distribution.

The issue is that I would like to do this automatic operation to be for any event - I do not want to manually surcharge every commonly used function (especially since I should define the task of working with the user f).

To give another example: I creates a random variable x with the domain [-2,1,1,1,1], and the probabilities [1 / 5,1 / 5,1 / 5,1 / 5, 1/5]

I have created a (strange) function such as f (x) = x if x = -2 or 2 f (x) = x ^ 2 otherwise

Mathematical, I know how to do this.

ps: I have not been formally trained in object-oriented programming, so I can sometimes use the wrong word for a concept.

Again, thanks for any help! Yes, you can overload the operators, however, whatever you are trying to do,

It is high if you need a simple input check with the isreal function. function deny complex (input value) if ~ isreal (inputValue) error ('input is not a real number') end

If you use this function If you enter a complex number in the form of input, this will display an error, otherwise it will not be. Now you can create your own function around it, so that all the code can be executed, when the condition is correct (hence, continue your work after this, after the end statement)

Comments