Write a MATLAB function called Ana3_Name with 1 input (Word) and 1 output (Res).
ID: 3778775 • Letter: W
Question
Write a MATLAB function called Ana3_Name with 1 input (Word) and 1 output (Res). The input (Word) should have at least 3 letters. The function randomizes the order of the letters of the input Word then generates 3 anagram words with decreasing number of letters by 1, starting with an anagram with the same number of letters as the input Word Use the outcome as an index to the original word. Use a For Loop and create a cell variable using the counter as an index. Examples of a working function are shown belowExplanation / Answer
% matlab code
function res = Ana3_Name(word)
if length(word) < 3
disp('word length should be atlest 3 ');
exit
end
res = [];
for i=1:3
p = randperm(length(word));
word = word(p);
res{i} = word;
%disp(word);
word = word(1:end-1);
end
end
res = Ana3_Name("AYUSH");
disp(res);
%{
output:
HAYSU
HYSA
SHY
%}
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.