Please find required MATLAB code along with necessary details in comments below:
--------------------------------------------------------- main_Script.m
clear all; clc;
str='pabc123'; % given string
filename='anagram.txt'; % file name where anagram have to be
written
anagram(str,filename); % call the function
-------------------------------------------------------------------------- anagram.m
function anagram(str,filename)
% remove all the letters from the string
index = find(isletter(str));
fstr=str(index);
% convert all letters to lower case
fstr=lower(fstr);
% unique charcters in the string
unique_char=unique(fstr);
n=length(unique_char); % number of unique charcters in the
string
% find all permulations of string
% all_comb=perms_letter(unique_char,n)
i=0;
for k=n:-1:1
i=i+1;
row_comb=[];
ntimes=n^(k-1);
for t=1:n^n/ntimes;
for j=1:n
% make all posssible combinations
row_comb=[row_comb;repmat(unique_char(j),ntimes,1)];
end
end
all_comb(:,i)=row_comb;
end
all_comb=cellstr(all_comb); % convert the chacter matrix into cell string
all_comb=unique(all_comb); % find unique strings from all
combinations
all_comb=sort(all_comb); % sort strings in alphabetical order
fileId= fopen(filename,'w'); % open the file
fprintf(fileId,'%s\n',all_comb{:}); % write data to file
fclose(fileId); % close the file
========================================== SCREENSHOT OF CODE
=============================================== SAMPLE OUTPUT
Extra Credit Function Name: anagram Inputs: 1. 2. (char) String representing the anagram (char) Name of...
Homework 02-Vectors, Strings, and Masking Function Name: forecast Inputs 1. (char) A character vector of the current forecast 2. (char) The word to be replaced 3. (char) The new word to put into the forecast Outputs 1. (char) The updated forecast description Banned Functions strrep), replace), regexprep() Background You have recently started your internship as a weather engineer at the local news station. Unhappy with how the curment forecasts are described as 'gloomy" and 'cold, you decide to use MATLAB...
Goal: Unscramble permuted words by generating all permutations of Jumble string and searching for a word in Unix dictionary. Unix Dictionary: dict.txt Details: Write a method called get_permutations that inputs a string like "dog". Your method should return an array of all permutations of the Jumble string. . For example: s = "dog" perms = get_permutations(a) print(perms) Output: ['dog', 'dgo', 'odg', 'ogd', 'gdo', 'god'] Rewrite the script for obtaining permutations and the end of the Comments, Hints, and Observersions section...
Add or Subtract. Write a function (add-sub-string s). The function consumes a Str of even length, where every even- numbered character is either "+" or "-", and odd-valued characters are numeric The function should add up all the digits that follow a "+", and subtract all the digits that follow a "-". For example, (add-sub-string "+3+4-5") => 2 (add-sub-string "-5+3+4-6-6") - 10 => The interface file contains the function char->nat that converts a numeric Char to the corresponding numeric value....
JAVA Recursion: For this assignment, you will be working with various methods to manipulate strings using recursion. The method signatures are included in the starter code below, with a more detailed explanation of what function the method should perform. You will be writing the following methods: stringClean() palindromeChecker() reverseString() totalWord() permutation() You will be using tools in the String class like .substring(), .charAt(), and .length() in all of these methods, so be careful with indices. If you get stuck, think...
for matlab Function Name: vineCompilation Inputs: (char) The first vine quote (char) The second vine quote Outputs: 1. (char) A “compilation” of the vines Background: It’s Sunday afternoon and you’re hanging out in your lounge, finishing off your Sprite Cranberry. Your Mom FriendTM (Jared, 19) walks in and yells at you for drinking soda for breakfast. Aggravated, you YEET the empty can down the hall as Jared drags you to the kitchen to make breakfast. You open the fridge to...
Programming language --> Matlab The name of a text file Outputs: (cell) An Nx2 cell array listing words and their counts in sorted order Function Description: Have you ever seen those fancy word-clouds based on the frequency of word occurrences in some text? Well the first step of making a graphic like that is to figure out how often the words in some text occur, which is exactly what this function will do. You will count the number of occurrences...
2. This question is about processing strings 2.1 [4 marks] Given a string str, we can calculate a checksum of the string by summing up the ASCII codes of the characters in the string. For example, the checksum of a string "apple" is 530, which equals to 'a' + 'p' + 'p' + 'l' + 'e' = 97 + 112 + 112 + 108 + 101. Write a function int calculate_checksum(char str[] that calculates and returns the checksum of the...
you need to write a C function named rem. The prototype is: int rem(char*, char*); The function accepts 2 strings: the first is a string of text to process; the second is where the output will be placed. rem() should remove all occurrences of a lowercase 'x' from the first string, and save the resulting string in the second arg. You may use the strlen() function; no other built-in fuctions should be used. Test your program thoroughly. Then, once you...
Write a function in matlab for these parameters (char) A string representing 7 days of the week (eg. 'N M T W R F S') (double) A vector representing 7 dates of the week (eg. [4 5 6 8 79 10]) (double) A positive or negative number of days (char) A string representing 7 days of the new week (double) A vector representing 7 dates of the new week circshift() It's fairly simple to determine what the date was or...