lab2 ex2

lab2 ex2

You cannot submit for this problem because the homework's deadline is due.

Ex2. Separate the digits (10 marks)

Read a natrual number from user input, and print a row vector containing all the digits of the number, from the highest decimal place to the lowest.

Requirement: You may not convert the number into a string or read it as a string. In other words, num2str() and input('','s') are banned.

Hint 1: Consider how you solved Lab 1 Ex2_2, but this time the input will not always be 3 digits long. You will need to use loops.

Hint 2: Create an empty vector [] and use array concatenation to append numbers to it.

Sample test cases

Input:

123

Output:

     1     2     3

Input:

114514

Output:

     1     1     4     5     1     4

Format

You should submit a compressed file containing a Matlab source file ex2.m

Lab2

Not Claimed
Status
Finished
Problems
6
Open Since
2023-05-23 18:00
DDL
2023-05-25 22:00
Extension
0.0 hour(s)