Question: (P2) (P9.2.5) In MATLAB, without using sort, implement the following function so that it performs as specfied: function a = compare1 ( s1 , s

(P2) (P9.2.5) In MATLAB, without using sort, implement the following function so that it performs as specfied: function a = compare1 ( s1 , s 2 ) % s1 and s2 are s t r i n g s % I f s1 comes before or is equal to s2 in t h e ASCII d i c t i o n a r y % order , t hen a i s 1 . Otherwise , a is 0 . Case is ignored. Here are some helpful implementation tips. (1) Pad the shorter string with blanks, i.e., add trailing blanks to make the two strings the same length. This will not affect the outcome. (2) Find the smallest integer k so that s1(k) is different than s2(k). Use a while-loop. If no such index exists, then the two strings are the same. (3) The value of a is one if and only if s1(k) <= s2(k) is true.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!