Write a single MATLAB statement that will accomplish the stated purpose. Assume
ID: 3782301 • Letter: W
Question
Write a single MATLAB statement that will accomplish the stated purpose. Assume a text string TS1 has already been defined. Find all occurrences of the string @3G in string TS1 and place the locations of the first character of each such substring (@) into Str3G. Example: TS1='%@3Gb6kl@3G9@33G' returns Str3G=[2 9].
Solution:
% Variables to be used
% Str3G - locations of first character of substring '@3G' in TS1
%% Inputs - Uncomment variables in this section to test in Matlab, but leave commented out when testing in Cody
% TS1 = ;
%% Start wrting your program here
Explanation / Answer
TS1='%@3Gb6kl@3G9@33G' ; %INITIALIZE TS1
Str3G= strfind(TS1,'@3G') %MATLAB FUNCTION TO FIND THE LOACTION OF SUB STRING IN THE GIVEN %STRING ,IT RETURNS A VECTOR CONTAINING THE LOCATION OF THE %SUBSTRING
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.