Please give me an explanation to understand the question.. Thank you for your he
ID: 3545013 • Letter: P
Question
Please give me an explanation to understand the question..
Thank you for your help, tried the coding myself, and got into trouble..
Thank you!
Take two strings inputs from the user and then finds all occurrences (first index number) of second input string in first input string. Solve it using builtin Matlab funciton strfind without using strfind Write a matlab script/function that takes a string as an input and checks whether the string is palindromes of not! Example Palindromes: A Toyota, Never odd or even ...Explanation / Answer
Problem(A)using strfind:
clc; clear all; % Ask for first input from user str1 = input('Enter First String:','s');
% ask for another input from user str2 = input('Enter Second String:','s');
% Find occurane of second in first index=strfind(str1,str2); [x,y]=size(index); i=1; while(i<=y) %Print Index of pattern matching in String index(i) i=i+1; end
without strfind
clc; clear all; % Ask for first input from user str1 = input('Enter First String:','s');
% ask for another input from user str2 = input('Enter Second String:','s');
[x,y]=size(str1); [x2,y2]=size(str2); k=1; for i=1:y j=1; if(str1(i)==str2(1)) while( i+j<y+1 && 1+j<y2+1 && str1(i+j)==str2(1+j)) j=j+1; end if(j==y2) index(k)=i+j-y2 k=k+1; end end end clc; clear all; % Ask for first input from user str1 = input('Enter First String:','s');
% ask for another input from user str2 = input('Enter Second String:','s');
[x,y]=size(str1); [x2,y2]=size(str2); k=1; for i=1:y j=1; if(str1(i)==str2(1)) while( i+j<y+1 && 1+j<y2+1 && str1(i+j)==str2(1+j)) j=j+1; end if(j==y2) index(k)=i+j-y2 k=k+1; end end end
Problem(B)
Program to check the entered number is palindrome or not
clc; clear all; str=input('Enter the string ','s'); [x,y]=size(str); j=0; mid=y/2; p=1; %checking string from start and end for i=1:mid if (str(i)~= str(y-j)) p=0; end j=j+1; end
if(p==1 && j>=mid-1) disp('Palindrome'); else disp('Not a Palindrome'); end
Problem(B)
Program to check the entered number is palindrome or not
clc; clear all; str=input('Enter the string ','s'); [x,y]=size(str); j=0; mid=y/2; p=1; %checking string from start and end for i=1:mid if (str(i)~= str(y-j)) p=0; end j=j+1; end
if(p==1 && j>=mid-1) disp('Palindrome'); else disp('Not a Palindrome'); end
Program to check the entered number is palindrome or not
clc; clear all; str=input('Enter the string ','s'); [x,y]=size(str); j=0; mid=y/2; p=1; %checking string from start and end for i=1:mid if (str(i)~= str(y-j)) p=0; end j=j+1; end
if(p==1 && j>=mid-1) disp('Palindrome'); else disp('Not a Palindrome'); end