USING MATLAB ONLY PLEASE COMMENT CODE IN DETAIL SHOW OUTPU

USING MATLAB ONLY - PLEASE COMMENT CODE IN DETAIL & SHOW OUTPUT

Write an M-file.- Write a Function.

Write a function that will accept two single ASCII characters and return a string message.

The message the function returns will be based on the following:

If the first character is greater than the second, the function will return the message ‘First greater than second’.

If the first character is less that the second, the function will return the message ‘First less than second’.

If the characters are equal, the function will return the message ‘First equal to second’.

I NEED THE CODE TO BE COMMENTED

THE FUNCTION TO BE TESTED!!!!!

SHOWN OUTPUT

EXPLAIN WHAT THEY MEAN BY SINGLE ASCII CHARACTERS

Solution

We can convert ASCII values to return a string by just wrapping it in double:

x=double(\'hello\')

x=104 101 108 108 111

Conversion:

[char(x)]

Output: hello

% Initial message is a string

m = \'Hello World\';
% Find the ASCII equivalent
n = double(m);
% Convert to string and flip it
encoded = fliplr(num2str(n))

Output: 001  801  411  111  78   23   111  801  801  101  27

% Take the encoded message and flip it

cf = fliplr(encoded);
% Find ASCII equivalents
n = str2num(cf);
% Convert to ASCII
decoded = char(n)

I have provided the answers for both ways conversion through examples, hope this helps.

USING MATLAB ONLY - PLEASE COMMENT CODE IN DETAIL & SHOW OUTPUT Write an M-file.- Write a Function. Write a function that will accept two single ASCII chara

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site