Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pig Latin is a language game in which words in English are altered. The objectiv

ID: 3870860 • Letter: P

Question

Pig Latin is a language game in which words in English are altered. The objective is to conceal the words from others not familiar with the rules. The reference to Latin is a deliberate misnomer, as it is simply a form of jargon, used only for its English connotations as a strange and foreign-sounding language.[1]

To translate a word into Pig Latin, move all letters up to, but not including the first vowel (a,e,i,o,u), to the end of the word and append the -ay suffix.

Pig to igpay

Latin to atinlay

School to oolschay

In to inay

Out to outay

Yes to esyay

STOP and THINK BEFORE YOU CODE.

Write a function in matlab that translates a string of English words to a string of Pig Latin words.

Explanation / Answer

CODE

%pig_latin.m file

function [new_string] = pig_latin(str)
new_string = '';
ay = 'ay';
words = strsplit(str,' ');
wordLength = length(words);
for k = 1 : wordLength
eachWord = words{k};
first_vowel = eachWord(find(ismember(eachWord,'aeiou'),1,'first'));
vowel_ind = strfind(eachWord, first_vowel);
   if vowel_ind >= 2
       % start new word at vowel index
       new_word_arr{k} = [eachWord(vowel_ind:end), eachWord(1:vowel_ind-1), ay, ' '];
   else
       % add 'ay' if word starts with vowel
       new_word_arr{k} = [eachWord, ay, ' '];
   end
end
% celldisp(new_word_arr);
% String cells together to form the output character array.
new_string = [new_word_arr{:}];

% demo.m file

disp(pig_latin('engineers rule the world'));

%output

%engineersay uleray ethay orldway

The above code gets what exactly need you

hope it helps you

If any queries regarding code get back to me please

thank you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote