i have to take out where i can make users input 5 sentenses and add my own sente
ID: 3565259 • Letter: I
Question
i have to take out where i can make users input 5 sentenses and add my own sentenses on here. because when i go to publish this, it wont publish because of user input. i want my 5 sentenses to be, Today is October 18,2014. It is a Saturday!. Dragonball z is on right now. I love this show! Goku is my favorite character.
fprintf('Trajectories of Objects Projected ')
fprintf('Question 1 ') %outputs ?1
fprintf(' ') %prints space
alpha = 'abcdefghijklmnopqrstuvwxyz0123456789'; %letters
vowel = 'aeiou'; %vowels
space = ' '; %spaces
for i = 1:5 %for loop for 5 sentences
str = input('Enter Sentence ','s'); %output to enter sentenses
str_cell = {str};
str_cell_array(i,:) = str_cell;
end %ends loop
%Count and display the total number of characters for each sentence
for i = 1:5 %loop for characters
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(string);
fprintf('The total characters in Sentence %d is %d ',i,count);
%output for total amout of character
end %end loop
% the number of special characters in each sentence
for i = 1:5 %start loop for special charters
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(string) - sum(ismember(lower(string),alpha));
fprintf('The total special characters in Sentence %d is %d '...
,i,count);
%output special charers total
end
%Ascertain and display the number of vowels in each sentence
for i = 1:5 %for loop for voewls
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = sum(ismember(lower(string),vowel));
fprintf('The total vowels in Sentence %d is %d ',i,count);
%output for vowels
end %end loop
%Ascertain and display the number of spaces in each sentence.
for i = 1:5 %for loop for spaces
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = sum(ismember(lower(string),space));
fprintf('The total spaces in Sentence %d is %d ',i,count);
%spaces in the sentences
end %end loop
%Ascertain and display the number of he"s in each sentence
for i = 1:5
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(strfind(lower(string),'the'));
fprintf('The total of "the" in Sentence %d is %d ',i,count);
end
%Ascertain and display the number of nd"s in each sentence
for i = 1:5
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(strfind(lower(string),'and'));
fprintf('The total of "and" in Sentence %d is %d ',i,count);
end
%Ascertain and display the most frequent word in ALL sentence
S = '';
for i = 1:5
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
S =[S string space];
end
example_paragraph = S;
words = regexp(example_paragraph, ' ', 'split');
vocabulary = unique(words);
n = length(vocabulary);
counts = zeros(n, 1);
for i=1:n
counts(i) = sum(strcmpi(words, vocabulary{i}));
end
[frequency_of_the_most_frequent_word, idx] = max(counts);
most_frequent_word = vocabulary{idx};
fprintf('frequent word is %s ',most_frequent_word);
Enter 5 sentences of your choice in MATLAJB. These sentences should comprise of letters, numbers, and special characters found on the keyboard.Explanation / Answer
fprintf('Trajectories of Objects Projected ')
fprintf('Question 1 ') %outputs ?1
fprintf(' ') %prints space
alpha = 'abcdefghijklmnopqrstuvwxyz0123456789'; %letters
vowel = 'aeiou'; %vowels
space = ' '; %spaces
str ='Today is October 18,2014.';
str_cell = {str};
str_cell_array(1,:) = str_cell;
str ='It is a Saturday!.';
str_cell = {str};
str_cell_array(2,:) = str_cell;
str ='Dragonball z is on right now.';
str_cell = {str};
str_cell_array(3,:) = str_cell;
str ='I love this show!';
str_cell = {str};
str_cell_array(4,:) = str_cell;
str ='IGoku is my favorite character.';
str_cell = {str};
str_cell_array(5,:) = str_cell;
%Count and display the total number of characters for each sentence
for i = 1:5 %loop for characters
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(string);
fprintf('The total characters in Sentence %d is %d ',i,count);
%output for total amout of character
end %end loop
% the number of special characters in each sentence
for i = 1:5 %start loop for special charters
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(string) - sum(ismember(lower(string),alpha));
fprintf('The total special characters in Sentence %d is %d '...
,i,count);
%output special charers total
end
%Ascertain and display the number of vowels in each sentence
for i = 1:5 %for loop for voewls
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = sum(ismember(lower(string),vowel));
fprintf('The total vowels in Sentence %d is %d ',i,count);
%output for vowels
end %end loop
%Ascertain and display the number of spaces in each sentence.
for i = 1:5 %for loop for spaces
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = sum(ismember(lower(string),space));
fprintf('The total spaces in Sentence %d is %d ',i,count);
%spaces in the sentences
end %end loop
%Ascertain and display the number of he"s in each sentence
for i = 1:5
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(strfind(lower(string),'the'));
fprintf('The total of "the" in Sentence %d is %d ',i,count);
end
%Ascertain and display the number of nd"s in each sentence
for i = 1:5
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
count = length(strfind(lower(string),'and'));
fprintf('The total of "and" in Sentence %d is %d ',i,count);
end
%Ascertain and display the most frequent word in ALL sentence
S = '';
for i = 1:5
str_cell = str_cell_array{i,:};
string = str_cell(1,:);
S =[S string space];
end
example_paragraph = S;
words = regexp(example_paragraph, ' ', 'split');
vocabulary = unique(words);
n = length(vocabulary);
counts = zeros(n, 1);
for i=1:n
counts(i) = sum(strcmpi(words, vocabulary{i}));
end
[frequency_of_the_most_frequent_word, idx] = max(counts);
most_frequent_word = vocabulary{idx};
fprintf('frequent word is %s ',most_frequent_word);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.