Question

Write a function called RemoveConsonants which removes all the consonants in a given phrase. The upper and lower case of the remaining characters should remain unchanged. The input and output phrases are string scalars. The input string could be any length. Hint: The function should work for both upper and lower case. Restrictions: Loops should not be used. The internal functions char(), string(), and ismember() should be used.Remove all consonants Write a function called RemoveConsonants which removes all the consonants in a given phrase. The upper and lower case of the remaining characters should remain unchanged. The input and output phrases are string scalars. The input string could be any length. Hint: The function should work for both upper and lower case. Restrictions: Loops should not be used. The internal functions char), string), and ismember) should be used Ex: >>1Jack and Jill went up the hill; >>output RemoveConsonants (s1) output = a aieu ei >S1The Super Mario Game Everyone Was Waiting For Is Finally Out. outputRemoveConsonants (s1) output e ue aio ae Eeoe a aii o I ia Ou.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

function s2- RemoveConsonants (s1) Convert the string sl into a character array using char () function s-char (s1); %Declare

Sample output:

>s1-Jack and Jill went up the hill >output-RemoveConsonants (sl) output a a ieuei >>s1-The Super Mario Game Everyone was

Code to copy:

function s2 = RemoveConsonants(s1)

    %Convert the string s1 into a character array using char() function

    s=char(s1);

    %Declare a string variable with consonants

    consonants = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWYZ';

    % Use ismember() function to remove all the consonants

    %from the given phrase and then convert result into a string

    %using string() function

    s2 = string(s(~ismember(s,consonants)));

end

Add a comment
Know the answer?
Add Answer to:
Write a function called RemoveConsonants which removes all the consonants in a given phrase. The upper...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Palindrome is a word or a phrase when taken in reverse order, gives the same word...

    Palindrome is a word or a phrase when taken in reverse order, gives the same word or phrase. For example, the word “radar” is a palindrome. The phrase "Do geese see God?" is also a palindrome after the removal of the question mark and all the spaces and the conversion of the remaining alphabets to either upper or lower case. Write a program that uses an STL stack to check if an arbitrary string containing multiple words separated by spaces...

  • Question 4 5 Write a function to upper that converts a string from lower case to...

    Question 4 5 Write a function to upper that converts a string from lower case to change it to "HELLO": Remember that you can test if a char is between 'a and z. inclusive, and that capital chars int main0i upper case. For the following function, to upper should accept hello as an are 32 less than lower case chars char sil "hello" printf("s-%s\n", s); to uppers): printf("s-%sin", s); return O: The program output should be: s hello s HELLO...

  • The program needs to be written in C. Write a function void camelCase(char* word) where word...

    The program needs to be written in C. Write a function void camelCase(char* word) where word consists of more than two words separated by underscore such as “random_word” or "hello_world_my_name_is_sam". camelCase() should remove underscores from the sentence and rewrite in lower camel case” (https:// en.wikipedia.org/wiki/Camel_case). Watch out for the end of the string, which is denoted by ‘\0’. You have to ensure that legal strings are given to the camelCase() function. The program should only run when the input is...

  • ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of...

    ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of a file. The program encoded sentences in the file and writes the encoded sentences to the output file. Enter the file name: messages.txt Output: encoded words are written to file: messages.txt.swt The program reads the content of the file and encodes a sentence by switching every alphabetical letter (lower case or upper case) with alphabetical position i, with the letter with alphabetical position 25...

  • Write a program that uses a recursive function to determine whether a string is a character-unit...

    Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences...

  • Problem 3 Write a function named repeat_words that takes two string parameters: 1. in_file: the name...

    Problem 3 Write a function named repeat_words that takes two string parameters: 1. in_file: the name of an input file that exists before repeat_words is called 2. out_file: the name of an output file that repeat_words creates Assume that the input file is in the current working directory and write the output file to that directory. For each line of the input file, the function repeat_words should write to the output file all of the words that appear more than...

  • Write C programs named mystring.h and mystring.c, containing the headers and implementations of the following functions....

    Write C programs named mystring.h and mystring.c, containing the headers and implementations of the following functions. int letter_count(char *s) computes and returns the number of English letters in string s. int word_count(char *s) computes and returns the number of words in string s. void lower_case(char *s) changes upper case to lower case of string s. void trim(char *s) removes the unnecessary empty spaces of string s. mystring.h #include <stdio.h> int letter_count(char *); void lower_case(char *); int word_count(char *); void trim(char...

  • Problem 1 Given a linked list of integers, write a function getUnique that removes all duplicates elements in the linked list and returns the new linked list of unique elements (The order does not ma...

    Problem 1 Given a linked list of integers, write a function getUnique that removes all duplicates elements in the linked list and returns the new linked list of unique elements (The order does not matter). Example: Input: 1-»2->3->1-2 Output: 1->2->3 public class Node f int iterm Node next; Node(int d) t item = d; next-null; ) import java.util.ArrayList; public class ExtraLab public static void main (String[] args)t PROBLEM 1 System.out.println("PROBLEM 1"); Node head new Node(1); head.next-new Node (2); head.next.next-new Node(3);...

  • Using python Question 13 (20 points) Write a function named Linestats that finds the number of...

    Using python Question 13 (20 points) Write a function named Linestats that finds the number of consonant and vowel letters on each line of a file and writes those statistics to a corresponding line of a new file, separated by a space. Definitions: A vowel letter is one of a, e, i, o, u, along with the corresponding uppercase letters..A consonant letter is not a vowel letter. The function linestats takes two parameters: 1. inFile, a string, the name of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT