MATLAB Programming Fundamentals - MathWorks
including an empty string, using double quotes. TF is a logical vector that contains a true value wherever sonnets contains a st ...
sonnets = strip(sonnets); sonnets(1:10) ans = 10x1 string array "THE SONNETS" "by William Shakespeare" "I" "From fairest creatur ...
"creatures" "we" Sort Words Based on Frequency Find the unique words in sonnetWords. Count them and sort them based on their fre ...
Display the ten most common words in the Sonnets. wordsByFrequency(1:10) ans = 10x1 string array "and" "the" "to" "my" "of" "i" ...
"thou" Collect Basic Statistics in Table Calculate the total number of occurrences of each word in sonnetWords. Calculate the nu ...
The most common word in the Sonnets, and, occurs 490 times. Together, the ten most common words account for 20.163% of the text. ...
Test for Empty Strings and Missing Values String arrays can contain both empty strings and missing values. Empty strings contain ...
if (str == "") disp 'str has zero characters' end str has zero characters Do not use the isempty function to test for empty stri ...
Find Empty Strings Within Other Strings Strings always contain the empty string as a substring. In fact, the empty string is alw ...
ans = "Hello, " Insert a substring after empty strings using the insertAfter function. Because there are empty strings between e ...
0 0 1 Compare str to a missing string. The comparison is always 0 (false), even when you compare a missing string to another mis ...
Formatting Text To convert data to text and control its format, you can use formatting operators with common conversion function ...
% 3$ 0 12 .5 b u Identifier Conversion character Flags Field width Precision Subtype Conversion Character The conversion charac ...
Subtype The subtype field is a single alphabetic character that immediately precedes the conversion character. Without the subty ...
Specify different field widths. To show the width for each output, use the | character. By default, the output text is padded wi ...
Character Description Example Pound sign (#) Modify selected numeric conversions: For %o, %x, or %X, print 0 , 0x, or 0X prefix ...
NoteYou can specify more than one flag in a formatting operator. Value Identifiers By default, functions such as sprintf insert ...
Special Character Representation in Format Specifier Character whose Unicode numeric value can be represented by the hexadecimal ...
If the precision p is greater than the number of digits f in the fractional part of the input, then p digits are shown after th ...
txt = sprintf('%*.2f', 5, 123.45678) txt = '123.46' Specify Numbered Identifiers in Width and Precision Fields You also can spec ...
«
7
8
9
10
11
12
13
14
15
16
»
Free download pdf