transpose

How to use `image` to display a matrix in its conventional layout?

孤街醉人 提交于 2019-12-01 11:51:26
I have a matrix defined as follows dataMatrix <- matrix(rnorm(400), nrow=40) then dataMatix is plotted to the screen using the following image(1:10, 1:40, t(dataMatrix)[, nrow(dataMatrix):1]) can someone explain how the third argument of the image function works ? I'm particularly confused by what happens inside [] . Thanks There is nothing better than an illustrative example. Consider a 4 * 2 integer matrix of 8 elements: d <- matrix(1:8, 4) # [,1] [,2] #[1,] 1 5 #[2,] 2 6 #[3,] 3 7 #[4,] 4 8 If we image this matrix with col = 1:8 , we will have a one-to-one map between colour and pixel:

Transpose some columns to rows using pivot with SQL

北城以北 提交于 2019-12-01 10:50:24
MS SQL Server 2012 I have a table called indexrows name displayname propertyvalue abc $row1 agg abc $row2 spx abc $row3 qqq def $row1 spx def $row2 qqq I would like to transpose these results to look like this. name $row1 $row2 $row3 abc agg spx qqq def spx qqq I tried the following query without success. I get this error Msg 156, Level 15, State 1, Line 10 Incorrect syntax near the keyword 'for'. select * from ( select name,propertyvalue, displayname from indexrows ) a PIVOT ( propertyvalue for [displayname] in ('$row1', '$row2', '$row3') ) as pivot Any help is appreciated. There are a few

Transpose column on one sheet to row on another, with linking

帅比萌擦擦* 提交于 2019-12-01 09:08:46
I have a column of data in say A1:A10 in worksheet A. In worksheet B I have a range for data from A1:J1. I need the data from the column in worksheet A to be transposed into the data range in worksheet B. I can Paste Special and paste in the values but I need the information in worksheet A to update automatically that in worksheet B. Any help or advice is appreciated. Please select A1:J1 in worksheet B and enter: =TRANSPOSE('worksheet A'!A1:A10) with Ctrl + Shift + Enter . Copy this: =INDEX(A!$A$1:$A$10, COLUMN()) into your cells A1 through J1 in worksheet B (so that all cells contain the

Transpose one row into many rows Oracle

◇◆丶佛笑我妖孽 提交于 2019-12-01 08:53:42
I have a query that always returns one row, with many columns. I would like to turn this into 2 columns and many rows. Original results: Col1, Col2, Col3, Col4 ---------------------- val1, val2, val3, val4 What I want: ColName, Value -------------- Col1, val1 Col2, val2 Col3, val3 Col4, val4 Is this possible? EDIT (clarification) I'm looking for an automatic way of doing this. IE something I can pass results from any query that only returns 1 line. Are you using Oracle 11g? Did you try pivot and unpivot? More info here . sure. Do select 'Col1' ColName, Col1 Value from srctable union all select

Transpose some columns to rows using pivot with SQL

和自甴很熟 提交于 2019-12-01 08:25:34
问题 MS SQL Server 2012 I have a table called indexrows name displayname propertyvalue abc $row1 agg abc $row2 spx abc $row3 qqq def $row1 spx def $row2 qqq I would like to transpose these results to look like this. name $row1 $row2 $row3 abc agg spx qqq def spx qqq I tried the following query without success. I get this error Msg 156, Level 15, State 1, Line 10 Incorrect syntax near the keyword 'for'. select * from ( select name,propertyvalue, displayname from indexrows ) a PIVOT ( propertyvalue

how to read a matrix from a text file in matlab

对着背影说爱祢 提交于 2019-12-01 08:15:50
问题 I have a text file which has 500 columns and 500 rows , of numerical(integer) values . Every element in the row is separated by a tab. I want to read this file as a matrix in matlab . Example(my text file is like this): 1 2 2 1 1 2 0 0 0 1 2 0 1 2 2 1 1 2 0 0 0 1 2 0 And after reading this text file as a matrix ( a[] ) in matlab I want to do transpose . Help me. 回答1: You can use importdata . Something like: filename = 'myfile01.txt'; delimiterIn = '\t'; headerlinesIn = 1; A = importdata

Transpose column on one sheet to row on another, with linking

帅比萌擦擦* 提交于 2019-12-01 06:08:32
问题 I have a column of data in say A1:A10 in worksheet A. In worksheet B I have a range for data from A1:J1. I need the data from the column in worksheet A to be transposed into the data range in worksheet B. I can Paste Special and paste in the values but I need the information in worksheet A to update automatically that in worksheet B. Any help or advice is appreciated. 回答1: Please select A1:J1 in worksheet B and enter: =TRANSPOSE('worksheet A'!A1:A10) with Ctrl + Shift + Enter . 回答2: Copy this

Matlab - Transpose a 3D matrix only in the third dimension

痴心易碎 提交于 2019-12-01 04:46:08
I have a 3 x 3 x 2 matrix, for example : M(:,:,1) = 1 2 3 4 5 6 7 8 9 M(:,:,2) = 10 11 12 13 14 15 16 17 18 and I would like to transpose each M(:,:,i) , I mean I would like to have : M(:,:,1) = 1 4 7 2 5 8 3 6 9 M(:,:,2) = 10 13 16 11 14 17 12 15 18 How is it possible to do this without loops ? Thank you very much ! That's what permute does: result = permute(M, [2 1 3]); %// swap dimensions 1 and 2 来源: https://stackoverflow.com/questions/27301188/matlab-transpose-a-3d-matrix-only-in-the-third-dimension

How to transpose matrix?

会有一股神秘感。 提交于 2019-12-01 04:09:18
I have made 8x8 matrix using c#, and now I need to transpose the matrix. Can you help me to transpose the matrix? This is my matrix public double[,] MatriksT(int blok) { double[,] matrixT = new double[blok, blok]; for (int j = 0; j < blok ; j++) { matrixT[0, j] = Math.Sqrt(1 / (double)blok); } for (int i = 1; i < blok; i++) { for (int j = 0; j < blok; j++) { matrixT[i, j] = Math.Sqrt(2 / (double)blok) * Math.Cos(((2 * j + 1) * i * Math.PI) / 2 * blok); } } return matrixT; } public double[,] Transpose(double[,] matrix) { int w = matrix.GetLength(0); int h = matrix.GetLength(1); double[,] result

Transposing arbitrary collection-of-collections in Scala

与世无争的帅哥 提交于 2019-12-01 03:34:59
I have to often transpose a "rectangular" collection-of-collections in Scala, e.g.: a list of maps, a map of lists, a map of maps, a set of lists, a map of sets etc. Since collections can be uniformly viewed as a mapping from a specific domain to a co-domain (e.g.: a List[A]/Array[A] is a mapping from the Int domain to the A co-domain, Set[A]is a mapping from the A domain to the Boolean co-domain etc.), I'd like to write a clean, generic function to do a transpose operation (e.g.: turn a map of lists to the transposed list of maps). However, I'm having trouble because other than the ()