× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Get input type 'char' in matlab functions

Ray Phan
Jul 02, 2015
<p>Use <a href="http://www.mathworks.com/help/matlab/ref/ischar.html" rel="nofollow"><code>ischar</code></a>. This checks to see if an input into this function is a character array, and reports <code>true</code> if it is and <code>false</code> otherwise. Take note that a single character is also a character array... it's simply a 1 x 1 array.</p> <p>Therefore, you could do something like this in your code:</p> <pre><code>function check(ip1, ip2) if ischar(ip1) %//... Do something if ip1 is a char else %//... Do something else if ip1 is not a char end if ischar(ip2) %//... Do something if ip2 is a char else %//... Do something else if ip2 is not a char end </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/31143832/Get%20input%20type%20'char'%20in%20matlab%20functions/31143976">Stack Overflow</a>.</p>
comments powered by Disqus