Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING MATLAB ONLY - PLEASE COMMENT CODE IN DETAIL & SHOW OUTPUT Write an M-file.

ID: 3930917 • Letter: U

Question

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

Write an M-file.

Using the for loop structure write a program to transpose a matrix.

In your script define an array A of order 2x3; you can use any random numbers you like and hardcode the numbers in the program. Now use the for loop structure to generate another array B that is the transpose of A. Finally display A and B. You must use the for loop structure. Hint: for a 2D array you will need to use a nested for loop structure.

Explanation / Answer

outlput:

A =                                                                                                                                                                 

                                                                                                                                                                    

   1.15404  -0.96827  -0.11630                                                                                                                                      

   0.21355  -1.08345  -1.04753                                                                                                                                      

                                                                                                                                                                    

Anew =                                                                                                                                                              

                                                                                                                                                                    

   1.15404   0.21355                                                                                                                                                

  -0.96827  -1.08345                                                                                                                                                

  -0.11630  -1.04753