Question: Please finish the following MATLAB function that takes a character vector ( str ) as the input and count the occurrence of the existing substring

Please finish the following MATLAB function that takes a character vector (str) as the input and count the occurrence of the existing substring (word). E.g. the call to the function
Count('This is a test.', 'test')
will return 1.
Function strfind(TEXT,PATTERN) returns the starting indices of any occurrences of PATTERN in TEXT.
function n=Count(str, word)
b=strfind(str,word);
_________
Question 5 options:
A)
if ~isempty(b)
n=size(b);
else
n=0;
end
B)
if isempty(b)
n=size(b);
else
n=0;
end
C)
if ~isempty(b)
n=length(b);
else
n=0;
end
D)
if isempty(b)
n=length(b);
else
n=0;
end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!