String array operations
a. Create a string array called myInformationcontaining the following entries in order:
b. Use the Matlab function strcmp to compare the name of the university as you defined it against the following two strings:
i. “The Ohio State University”
ii. “THE OHIO STATE UNIVERSITY”
Use variables called prob2bi and prob2bii to store the results of the comparisons.
c. Use the Matlab function strcmpi to compare the name of the university as you defined it against the following two strings:
i. “The Ohio State University”
ii. “THE OHIO STATE UNIVERSITY”
Use variables called prob2ci and prob2cii to store the results of the comparisons.
If the difference between strcmp and strcmpi is not obvious from the example, look them up in the Matlab documentation.
d. Extract your name from the string array and convert it to a char array called myName.
e. Change the part of myName containing your first name to 'Brutus'. (For example, if your name was originally 'James E. Toney', it will now be 'Brutus E. Toney'.) YOU SHOULD BE ABLE TO DO THIS WITHOUT RE-CREATING THE WHOLE CHAR ARRAY FROM SCRATCH - USE CONCATENATION AS NEEDED
a. Create a string array called myInformation containing the following entries in order:
myInformation = ["James E. Toney", "Florida", "CS", "The Ohio State University"]
b. Use the Matlab function strcmp to compare the name of the university as you defined it against the following two strings:
prob2bi = strcmp(myInformation(4), “The Ohio State University”)
prob2bii = strcmp(myInformation(4), “THE OHIO STATE UNIVERSITY”)
c. Use the Matlab function strcmpi to compare the name of the university as you defined it against the following two strings:
prob2ci = strcmpi(myInformation(4), “The Ohio State University”)
prob2cii = strcmpi(myInformation(4), “THE OHIO STATE UNIVERSITY”)
strcmp is case sensitive wheras strcmpi is case insensitive
d. Extract your name from the string array and convert it to a char array called myName.
myName = char(myInformation(1))
e. Change the part of myName containing your first name to 'Brutus'.
myNametemp = split(myName)
myName=char(strcat("Brutus ",myNametemp(2)," ",myNametemp(3)))
Get Answers For Free
Most questions answered within 1 hours.