This must be done in matlab. You may not use the built-in function reverse or an
ID: 3794356 • Letter: T
Question
This must be done in matlab.
You may not use the built-in function reverse or any other functions that automatically reverse strings for this problem! Write a function that receives a string variable as an input argument and returns a backward string. For example, if the input argument is Thanksgiving follows Halloween the output should be neewollaH swollof gnivigsknah Call this function from a script file, which user input, passes it to the function, and then outputs the result to the command window Modify part (a) in such a way that the output gives you the backward sentence. For example, if the input argument is Thanksgiving follows Halloween, the output should be Halloween follows Thanksgiving. To make the problem a little easier, do not use punctuation in your input argument and separate the words with only one space. Again, call this function from a script file. This problem has 10 points.Explanation / Answer
(a) function(t) = reverse(str)
len=length(str);
t = str(::-1)
(b) function(t) = reverse_sent(str)
len=length(str);
t='';
while(len>0)
[token,str]=strtok(str);
len=length(str);
%token=fliplr(token);
%t=[token,' ',t];
t=[' ',token,t];
end
display(t);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.