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
  • Write a C program to assign natural numbers 1 to 100 into a one-dimensional integer array....

    Write a C program to assign natural numbers 1 to 100 into a one-dimensional integer array. Display all the values in the array on the screen. For each number in the array, determine if the number contains digit 7 or is divisible by 7. Display all those numbers on the screen. Original array: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27...

  • In Java, declare a 2-dim array called matrix which holds up to 35 values (of type...

    In Java, declare a 2-dim array called matrix which holds up to 35 values (of type int) 5 rows and 7 columns each. Using sub-array processing and modularity, create methods to do the following: 1. Fill the array matrix with random numbers between 1-100 2. Compute the cumulative sum of the array matrix 3. Using column-wise processing compute, and print the cumulative sum of all the elements in each column 4. Compute the min value of the array matrix 5....

  • 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...

  • Python 3 Create a function that takes an array and an integer v, and returns the...

    Python 3 Create a function that takes an array and an integer v, and returns the number of v occurrences in the array. Add a variable Nsteps to count how many times the loops have executed and display that information in a message The main program must take an array / list 2D, call the function, and display the result. >>>l3 = [52, 14, 14, 8, 85, 69, 1, 77, 94, 96, 51, 65, 35, 32, 87, 92, 74, 47,...

  • 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?

  • 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...

  • 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...

  • 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...

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