Question

Create a function to transpose Array elements as follows: (Problem Set 11 #1)

Transposed 10 X 10 Array -- Sample Output NOTE: This NOT a matrix transpose. (ie: rows to columns) This is simply moving el

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB CODE

function A = TransposeArray(A) [row,col]=size(A); % dimension of matrix k=row;  for i=1:row/2 % Will run loop for half number of columns     temp=flip(A(k,:));   % k will contain index of last column and flip  will reverse that column          A(k,:)= flip(A(i,:));   % Swapping rows(flipped) to first and last     A(i,:)=temp;     k=k-1;  % Decrease index of last to last -1 for next swapping                end end

RESULTS :

>> a=[1 2 5 4 3 5;4 4 2 5 5 6;7 52 4 12 8 9]
a =
1 2 5 4 3 5
4 4 2 5 5 6
7 52 4 12 8 9
>> TransposeArray(a)
ans =
9 8 12 4 52 7
4 4 2 5 5 6
5 3 4 5 2 1
>>
>> B=[1 21 15 41 322 52 21;4 4 2 5 5 60 621;7 52 4 12 82 9 80;7 23 123 31 45 89 90]
B =
1 21 15 41 322 52 21
4 4 2 5 5 60 621
7 52 4 12 82 9 80
7 23 123 31 45 89 90
>> TransposeArray(B)
ans =
90 89 45 31 123 23 7
80 9 82 12 4 52 7
621 60 5 5 2 4 4
21 52 322 41 15 21 1
>>

Add a comment
Know the answer?
Add Answer to:
Create a function to transpose Array elements as follows: (Problem Set 11 #1) Transposed 10 X...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D...

    Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10. 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • F a as a sequence of adjacent array elements such that each value in the run array was of size 10...

    f a as a sequence of adjacent array elements such that each value in the run array was of size 10 9. We define a "run" of elements o (except for the first) is one greater than the previous and looked like: value. For example, say the 3 2 16 9 7 8 9 2 a: position 0 3 We have three runs in this array: (1) between 9,10,1, 12) and, (3) between positions 7 and 8, (15, 16) positions...

  • Python Question: In [76]: arr3d = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10,...

    Python Question: In [76]: arr3d = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]) In [77]: arr3d Out[77]: array([[[ 1, 2, 3], [ 4, 5, 6]], [[ 7, 8, 9], [10, 11, 12]]]) In [78]: arr3d[0] Out[78]: array([[1, 2, 3], [4, 5, 6]]) Can someone tell me why arr3d[0] is a  2 × 3 array?

  • The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random...

    The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random numbers from 1 to 100. – It asks the user for an index value between 0 and 99. – Prints the element at that position. – If a number > 99 is entered by the user, the class will abort with an ArrayIndexOutOfBoundsException • Modify the ExceptionLab: – Add a try-catch clause which intercepts the ArrayIndexOutOfBounds and prints the message: Index value cannot be...

  • 2. Given the array A = [2 4 1; 6 7 2; 3 5 9]. Provide...

    2. Given the array A = [2 4 1; 6 7 2; 3 5 9]. Provide appropriate the Matlab commands needed to a. calculate the determinant of A b. show the transpose of A c. Calculate the trace of A d. compute the sum over all rows of A

  • 5. Mark’s class just took the admission test for business school and averaged 87.05. Chapter 10...

    5. Mark’s class just took the admission test for business school and averaged 87.05. Chapter 10 Data Set 2 contains the population of scores for the 10 other classes in Mark’s university. How did Mark’s class do? Class 1 Class 2 Class 3 Class 4 Class 5 Class 6 Class 7 Class 8 Class 9 Class 10 78 81 96 85 88 78 90 79 96 86 77 78 97 90 88 82 86 93 87 89 78 93 88...

  • Write a C function  f such that … function  f accepts, as input, … a two-dimensional array of...

    Write a C function  f such that … function  f accepts, as input, … a two-dimensional array of integers in which each row has three columns the number of rows in the array function  f returns the sum of the odd integers in the given array of integers and returns zero if there are no odd integers in the array COMPILER STACK TRACE None PROGRAM EXECUTION STACK TRACE None COMPILER COMMAND LINE ARGUMENTS -lm INPUT OF THE TEST CASE 1 #define NUM_ROWS 5...

  • Hot 101 K-2 = 5 = 7 = 8 F9 10 11 The following data are...

    Hot 101 K-2 = 5 = 7 = 8 F9 10 11 The following data are the grades of 17 students on an algebra test. 91, 78, 60, 77, 76, 87, 69, 89, 59, 68, 57, 58, 83, 82, 93, 81, 60 Using the tool provided, construct a box-and-whisker plot for the data. Х 5 ? 55 60 65 70 75 80 85 90 95 Score on algebra test

  • Final Project For this assignment, use data from W1 Assignment. Using Minitab. Give instructions on how...

    Final Project For this assignment, use data from W1 Assignment. Using Minitab. Give instructions on how to insert data into Minitab. This week, you will explore the hypothesis that higher levels of stress are associated with lower levels of confidence. Compute the correlation between the stress score and confidence scores. StressScore   Confidence 3   100 5   112 2   125 9   150 7   136 4   107 3   143 1   141 4   134 2   148 5   139 3   117 7   76 8   99...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT