matrix

How to create NxM Corr matrix from Column 2 of 2xN signals in R?

孤人 提交于 2019-12-30 14:45:13
问题 I have 2x N amount of 1D Signals in files where Column 1 is Signal 1 and Column 2 Signal 2. Code 1 is simplified example about 1x N amount of 1D signals, while Code 2 is the actual target with two pieces of pseudocode about: to create two dimensional vector ( files[[i]] = i,i+1 ) - just two integer data units in each row separated by comma, and and then accessing the data there later ( tcrossprod( files[[]][, 2], files[[]][, 2] ) ) where I cannot refer to all columns 2 of all signals

How to combine all rows into a single row? [closed]

混江龙づ霸主 提交于 2019-12-30 14:44:12
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I have a dataframe which has 100 rows and 10 columns, i wonder how I can merge all the 100 rows into just one row? Thanks. mydata=seq(1,1000) mydata=as.data.frame(matrix(mydata,nrow = 100,ncol = 10,byrow=T)) the result should be like this:(just a single row) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

How to combine all rows into a single row? [closed]

别等时光非礼了梦想. 提交于 2019-12-30 14:44:09
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I have a dataframe which has 100 rows and 10 columns, i wonder how I can merge all the 100 rows into just one row? Thanks. mydata=seq(1,1000) mydata=as.data.frame(matrix(mydata,nrow = 100,ncol = 10,byrow=T)) the result should be like this:(just a single row) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Why is this matrix not numeric? Then `as.numeric` destroys the matrix and return a vector

半世苍凉 提交于 2019-12-30 12:19:20
问题 I have a data frame called input . The first column refers to an Article ID ( ArtID ), the subsequent columns will be used to create the matrix. Based on the ArtID , I want R to generate a 2x2 matrix (more precise: It needs to be a numeric 2x2 matrix ). Specifically, I want to create a matrix for the first row ( ArtID == 1 ), the second row( ArtID == 2 ) and so on... What I came up with so far is this: for(i in 1:3) {stored.matrix = matrix(input[which(ArtID ==i),-1],nrow = 2) This gives me a

Swift matrix sum

喜夏-厌秋 提交于 2019-12-30 12:16:10
问题 I'm trying to develop a func which allows to sum two matrix if they are equals to the same dimension, but I get an error "EXC_BAD_INSTRUCTION" on the try. Here is my Playground: import Foundation enum RisedError: ErrorType { case DimensionNotEquals case Obvious(String) } func ==(lhs: Matrix, rhs: Matrix) -> Bool { return (lhs.rows) == (rhs.rows) && (lhs.columns) == (rhs.columns) } protocol Operation { mutating func sumWith(matrixB: Matrix) throws -> Matrix } struct Matrix { let rows: Int,

Swift matrix sum

一世执手 提交于 2019-12-30 12:15:46
问题 I'm trying to develop a func which allows to sum two matrix if they are equals to the same dimension, but I get an error "EXC_BAD_INSTRUCTION" on the try. Here is my Playground: import Foundation enum RisedError: ErrorType { case DimensionNotEquals case Obvious(String) } func ==(lhs: Matrix, rhs: Matrix) -> Bool { return (lhs.rows) == (rhs.rows) && (lhs.columns) == (rhs.columns) } protocol Operation { mutating func sumWith(matrixB: Matrix) throws -> Matrix } struct Matrix { let rows: Int,

AS3: Getting the scale of a Matrix object

十年热恋 提交于 2019-12-30 11:33:10
问题 Most often, questions are asked about how to scale a DisplayObject, and the answer is usually to use a Matrix. My question is, how to you GET the scale of a Matrix (scaleX and scaleY)? There's a Matrix.scale method to set the scaleX and scaleY, but it doesn't return a value, and no other properties exist to read it back. The reason I ask, I'm using object burried deep down into a Display list, and each may be transformed. So I use the child object's sprite.transform.concatenatedMatrix getter,

solving Ax =b for a non-square matrix A using python

帅比萌擦擦* 提交于 2019-12-30 11:22:09
问题 I'm focusing on the special case where A is a n x d matrix (where k < d) representing an orthogonal basis for a subspace of R^d and b is known to be inside the subspace. I thought of using the tools provided with numpy , however they only work with square matrices. I had the approach of filling in the matrix with some linearly independent vectors to "square" it and then solve, but I could not figure out how to choose those vectors so that they will be linearly independent of the basis vectors

Vector as column index in matrix

妖精的绣舞 提交于 2019-12-30 11:09:52
问题 Given a matrix A ( mxn ) and a vector B ( mx1 ) I want to create a vector C ( mx1 ) in which each row element is the row element of A from a column indexed by B . Is it possible to do this, without using loops? A = [1 2; 3 4; 5 6]; B = [2 1 1].'; Then I want: C = [2 3 5].'; 回答1: Convert the column subscripts of B to linear indices and then use them to reference elements in A : idx = sub2ind(size(A), (1:size(A, 1)).', B); C = A(idx); (for more information, read the part about linear indexing

Vector as column index in matrix

主宰稳场 提交于 2019-12-30 11:09:05
问题 Given a matrix A ( mxn ) and a vector B ( mx1 ) I want to create a vector C ( mx1 ) in which each row element is the row element of A from a column indexed by B . Is it possible to do this, without using loops? A = [1 2; 3 4; 5 6]; B = [2 1 1].'; Then I want: C = [2 3 5].'; 回答1: Convert the column subscripts of B to linear indices and then use them to reference elements in A : idx = sub2ind(size(A), (1:size(A, 1)).', B); C = A(idx); (for more information, read the part about linear indexing