![]() ![]() ![]() If you can construct the vector (1,3,5,2,4,6), then you can use that vector to assign the values appropriately. To make the point, consider the transpose of the above matrix: 1 2 The value in (1,3) can be referenced as A(5).Īs such, if you can construct a vector referencing the values in the transposed order, then you can assign the new values into the appropriate order and store them in a matrix of appropriate size. To reference the value in (2,2), you can reference it as A(2,2), or as A(4). Matlab stores values in a matrix in the form of a vector and a "size" - for instance, a 2x3 matrix would be stored with six values in a vector, and then (internally) to tell it that it's 2x3 and not 6x1.įor the 2x3 matrix, this is the order of the values in the vector: 1 3 5 I'm assuming that you are looking for a method that involves manually transposing the information, rather than using builtin functions. Putting this altogether, we can write a mex file in C++ that implements the transpose algorithm: #include "mex.As this is for a class, I won't give you an exact answer, but I will nudge you in the right direction. Note that this example uses transpose rather than the complex conjugate transpose. Method: transpose data, store it in cell array, reassign it to structure/field. The array tmp is used to index into prowB and elemsB when adding a new element and then is updated accordingly. Here's a simple method that you could do in 1 line of code. Then elemsB and prowB can be populated as follows for j = 1.,n Now suppose that tmp has been overwritten by its cumulative sum. Hence, the cumulative sum of tmp is the same as pcolB. Then it follows that tmp(i + 1) is the number of elements in column i of B. Let tmp be an array such that tmp(1) = 0 and tmp(i + 1) is the number of elements in row i of A for i = 1.,m. To do so, we use the fact that the rows of A form the columns of B. If B denotes the transpose of A, then our goal is to define the analogous arrays elemsB, prowB, pcolB.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |