Illustration of finding a sting, MATLAB in Engineering

Illustration of finding a sting:

Let's enlarge this, and write a script which creates a vector of strings which are phrases. The outcome is not suppressed so that the strings can be seen whenever the script is executed. It loops throughout the vector and passes each and every string to a function countblanks. This function counts the number of the blank spaces in a string, not involving any leading or trailing blanks.

140_Illustration of Finding a sting.png

1727_Illustration of Finding a sting1.png

 

For illustration, running this script would result in:

>> phraseblanks

phrasemat =

Hello and how are you?

Hi there everyone!

How is it going?

Whazzup?

Phrase 1 had 4 blanks

Phrase 2 had 2 blanks

Phrase 3 had 3 blanks

Phrase 4 had 0 blanks

Posted Date: 10/20/2012 5:32:21 AM | Location : United States







Related Discussions:- Illustration of finding a sting, Assignment Help, Ask Question on Illustration of finding a sting, Get Answer, Expert's Help, Illustration of finding a sting Discussions

Write discussion on Illustration of finding a sting
Your posts are moderated
Related Questions
Finding products by for loop: an illustration, when 5 is passed to be the value of the input argument n, the function will compute and return 1 + 2 + 3 + 4 + 5, or 15: >> s

Expanding a function: The expand function will multiply out terms, and factor will do the opposite: >> expand((x+2)*(x-1)) ans = x^2 x-2 >> factor(ans)

Illustration of gauss-jordan: Here's an illustration of performing such substitutions by using MATLAB >> a = [1 3 0; 2 1 3; 4 2 3] a = 1 3 0 2 1 3 4 2

ischar function: The ischar function return the logical true if an array is a character array, or logical false if not. >> vec = 'EK127'; >> ischar(vec) ans =

Displaying expressions: The good-looking function will show such expressions by using exponents; for illustration, >> b = sym('x^2') b = x^2 >> pretty(b)

Uses of Function handles: The Function handles can also be generated for functions other than anonymous functions, both built-in & user-defined functions. For illustration, th

Function fieldnames - structure functions: The function fieldnames will return the names of the fields which are contained in the structure variable. >> pack_fields = fiel

Subfunctions: Though, it is possible to have more than one function in a given M-file. For illustration, if one function calls the other, the first function would be the prima

For Loops which do not use an iterator Variable in the action: In all the illustrations that we seen so far, the value of the loop variable has been used in same way in the ac

Set Operations: The MATLAB has numerous built-in functions which perform set operations on vectors. These involve intersect, union, setdiff, unique, and setxor. All these func