Author Archives: arodriguezm

How to check if a viable is even or odd

Oldest question in the history of humanity… If the number is even, the remainder after the division by 2 is zero, and 1 if the number is odd, so using rem function (which actually calculates the remainder of the division between … Continue reading

Posted in checking format | Leave a comment

How to rotate a simple plot

Some times you would need to rotate your figure to display the axis rotated 90 degrees counter clockwise. The easiest way to do this rotating the view. You can do this using the command view as follows: view([-90 90]) If you … Continue reading

Posted in Plots | Leave a comment

How to determine if the input is a scalar real number

Some times it is interesting to know whether the input is a scalar real number, as for example if we are trying to introduce the sampling frequency of a sequence. We can use some of the following commands: isscalar:   … Continue reading

Posted in arrays, checking format, data format | Tagged , | Leave a comment

How to check array dimensions

There are a few matlab commands to determine array size or shape: length:  finds the number of elements along the largest dimension of an array. ndims:  returns the number of dimensions of the array. size:      returns the sizes of each … Continue reading

Posted in arrays | Tagged , | Leave a comment

How to determine whether input belong to a set of numbers

The easiest way is to sum up the result of the comparison between the input and the array. For example, imagine that you have an array of numbers x and you want to know if 5 is one of these numbers. You … Continue reading

Posted in Sin categoría | Tagged , | Leave a comment

How to determine whether input is integer

The easiest and fastest way to check if a variable is an integer independently of its format is to compare the input with its rounded version, for example: x==floor(x) If we are just interested in knowing if the input is an … Continue reading

Posted in Sin categoría | Tagged , , | Leave a comment