Basic operations with matrices matlab create two arrays perf
Basic operations with matrices. (matlab) create two arrays, perform some manipulations on the arrays and print the results to the screen
Solution
Creating an array in MATLAB is simple. We just need to declear -
A1=[2 5 7 9]
A2=[10 12 13 16]
Now to display or print we can use the command-
disp(A1)
The output is-
2 5 7 9
As the same
disp(A2)
10 12 13 16
Now we want to do some operations on these arrays. If we want to flip the elements in those two arrays we can use the command flip as follows-
A3=flip(A1)
A4=flip(A2)
Now to display we use the same mentioned before-
disp(A3)
9 7 5 2
disp(A4)
16 13 12 10
Now we want to sort the elements of the array in desending order. We can do this with the help of sort command as follows-
A5= sort(A1,\'descend\')
disp(A5)
9 7 5 2
We can apply it on array A2 also.
A6= sort(A2,\'descend\')
disp(A6)
16 13 12 10
