Questions tagged [matrix]

In mathematics, a matrix (plural matrices) is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. The individual items in a matrix are called its elements or entries.

matrix
Filter by
Sorted by
Tagged with
0 votes
2 answers
641 views

Moving matrix from c++ to Matlab

I'm trying to take a matrix from c++ and import it to Matlab to run bintprog on this matrix, call it m. My c++ code generates these matrices of a certain type, and I need to run bintprog on them ...
KevinShaffer's user avatar
2 votes
2 answers
99 views

Why i can't compile without declare a matrix like const

My doubt is: why in this code: /*Asignacion de valores en arreglos bidimensionales*/ #include <stdio.h> /*Prototipos de funciones*/ void imprimir_arreglo( const int a[2][3] ); /*Inicia la ...
Chris Galard's user avatar
1 vote
1 answer
2k views

Assign vector elements to matrix by coordinates MATLAB

I have a vector of values which i want to assign to a NxN matrix. The vector values correspond to the lower half of the matrix,but the matrix is symmetric. The problem is that the vector values are ...
user2091461's user avatar
2 votes
1 answer
4k views

Running a Fisher test on each row of a data frame in R

I have a data frame of ~50k measurements taken by ~3k investigators. INVESTIGATOR_ID \\\ SAMPLE_ID \\\ MEASUREMENT 1000 \\\ 38942 \\\ 20.1 1000 \\\ 38942 \\\ 10.2 1001 ...
user1357079's user avatar
0 votes
2 answers
162 views

blocking matrix in matlab

Suppose that I have a matrix with non square size such as 30X35 and I want to split into blocks such as 4 blocks it would be like 15X18 and fill the added cell by zeros could that be done in matlab?
Alyafey's user avatar
  • 1,455
3 votes
1 answer
2k views

How do I reflect a matrix in matplotlib?

I have created a matrix in matplotlib. As you can see it only covers half of the matrix. Is there anyway that I can reflect the points onto the other side of the matrix so I can fill the whole matrix? ...
John Smith's user avatar
  • 1,099
4 votes
1 answer
1k views

Finding indices of multiple items in a matrix?

I have an array of elements and I want to see the indices of them inside another matrix For example, for A = [1 2 3] B = [1 2 3 4 5 3 4 5 1 2 3] then result array C = [1 2 3 6 9 10 11] that ...
erogol's user avatar
  • 13.4k
4 votes
1 answer
951 views

How to group rows with same column values?

Given the matrix with coordinates in 3D space and values for two variables (say a and b) in two matrices I would like to merge rows for same points into a common matrix. To clearly explain the matter,...
Niko Gamulin's user avatar
  • 66.3k
0 votes
2 answers
554 views

Finding those pixels that meet a specific criterion

Attached is an image of cameraman.tif that comes with matlab but after applying [fuzzy c-means] 1 Also, as an output from the algorithm is u2 (degree of membership of a pixel). See matlab.mat for ...
Simplicity's user avatar
  • 48.3k
0 votes
4 answers
459 views

How can I generate the following Matrices in Matlab - fast method?

I have two input variables: N=10; M=4; Using Matlab, I want to generate the following matrices - without using for loops, for any M and N: %N = 1 2 3 4 5 6 7 8 9 Mat1 = [2, 3, 4, ...
uhnucross's user avatar
  • 103
1 vote
1 answer
2k views

Implement 2x2 rotation matrix in c#

I rotate a vector using the following code: var newVectorX = Math.Cos(step) * normalizedVector.X - Math.Sin(step) * normalizedVector.Y; var ...
Lama's user avatar
  • 2,916
3 votes
1 answer
2k views

How to convert decimal to different base-N on MATLAB?

I have two matrix A & B. Matrix A size 1x1013 double and matrix B size 1x12931 double. I want to convert each element of matrix A into base-N from matrix B. For example, first element of matrix A ...
user2089943's user avatar
0 votes
2 answers
794 views

How can I make a c++ program to find the determinate and inverse of any sized matrix?

I know how to find these in a 1x1 2x2 and 3x3 but I want to make a program that lets me enter the dimensions of my matrix and then enter the numbers that go in the matrix. After entering the numbers I ...
Matthew's user avatar
5 votes
1 answer
4k views

How rotate a 3D cube at its center XNA?

I try to rotate a 3D cube on itself from its center, not the edge. Here is my code used. public rotatemyCube() { ... Matrix newTransform = Matrix.CreateScale(scale) * Matrix.CreateRotationY(...
Mehdi Bugnard's user avatar
1 vote
2 answers
1k views

Signed distance matrix in R

[Note, I wrote out this question, then found an answer. I thought maybe someone else would like to know it, so I'm posting the answer just in case. I'm not sure if this is the "done thing"]. Suppose ...
Daniel Egan's user avatar
1 vote
1 answer
1k views

Get the product of two one dimensional numpy matrices

I have two one-dimensional numpy matrices: [[ 0.69 0.41]] and [[ 0.81818182 0.18181818]] I want to multiply these two to get the result [[0.883, 0.117]] (the result is normalized) If I use np....
oleron's user avatar
  • 483
1 vote
1 answer
1k views

Polynomial transformation of matrix in R

Perhaps a trivial question, but as output of R package ptw I have a set of polynomial coefficients (stored in slot warp.coef) which specify a polynomial transformation of the time axis. E.g. ...
Tom Wenseleers's user avatar
1 vote
3 answers
3k views

Access multiple channels in OpenCV Mat

What is the Syntax to access ith row of channel::n of a multi channel matrix. I can access (i,j) element of channel::n but what is the syntax to use functions like row, rowRange, ..... Sample Code: ...
santiago_apr1's user avatar
2 votes
1 answer
150 views

Matlab execute function each cell Matrix with matrix and cell postion as arguments

I need to apply a function to each pixel of each image in a set of ~400 images. The function I wrote (called customf) requires 3 arguments: the matrix, and the position of the cell in the matrix (m ...
Ben's user avatar
  • 966
3 votes
0 answers
2k views

floor of a matrix in OpenCV 2.4.3

I have a matrix of type Mat. I want to calculate floor of the Mat. I have searched the Operations on Arrays and The core functionality documentation. Below is a sample code Mat M = (Mat_<double&...
santiago_apr1's user avatar
1 vote
4 answers
266 views

List all products for a given product ID in R

I am very new to R so I apologize if this question is relatively novice. I have a list of roughly 33,000 rows that shows order ID and products ordered within that order ID. Structured as follows: ...
LFoos24's user avatar
  • 283
2 votes
2 answers
5k views

Filter matrix rows based on value of function in Matlab

This seems like a simple question but I have been unable to find an answer anywhere. If I have a Matlab matrix A consisting of an arbitrary number of rows, how would I filter these rows based on the ...
arshajii's user avatar
  • 129k
0 votes
2 answers
6k views

R independent columns in matrix

I am trying to find independent columns to solve the system of linear equations. Here my simplified example: > mat = matrix(c(1,0,0,0,-1,1,0,0,0,-1,1,0,0,0,-1,0,-1,0,0,1,0,0,1,-1), nrow=4, ncol=6, ...
user1981275's user avatar
  • 13.2k
-1 votes
1 answer
781 views

Matrix of differences in Python, result like MATLAB's bsxfun [duplicate]

I have a Nx1 vector of values. What I would like to do is create a NxN matrix where each value represents the difference between the ith and jth value - sort of like a large correlation matrix. I've ...
Jason Strimpel's user avatar
1 vote
1 answer
276 views

R: Can a matrix be populated in a loop by indexing both rows and columns?

I am a biologist and an R newbie, and I'm learning how to create a simple population model. So, I have a population matrix ("pop")of 30 age classes of female (1:4 are non-breeders, 5:30 are breeders) ...
Sam's user avatar
  • 13
2 votes
0 answers
138 views

HTML5 scaling translating yields wrong position

I have the following code which helps in transforming the images on the canvas based on the values obtained via the matrix value from the gesture control in winjs. Trial 1: At first i tried using ...
Hariharan Subramanian's user avatar
0 votes
0 answers
246 views

strange int values read by read function

I am doing an exercize, where you are required to read on a 32bit Little endian machine a binary file of this kind: 30002000100020003000400050006000 This kind of file describes a matrix with int ...
Germano Massullo's user avatar
0 votes
2 answers
550 views

How can I loop a data matrix in R?

I am trying to loop a data matrix for each separate ID tag, “1”, “2” and “3” (see my data at the bottom). Ultimately I am doing this to transform the X and Y coordinates into a timeseries with the ts()...
Joeri's user avatar
  • 167
2 votes
2 answers
132 views

read matrix from fixed-width file in R

i'm new in the R world, i have a file that contain a row series like this: "0000010000010000000101000001000000011000000001 0000000000000000000000010001000001001000110001 ...
Luca's user avatar
  • 1,290
0 votes
1 answer
1k views

Android OpenGL rotation matrix deformation

In my renderer, i have: private float[] MATRIX_VIEW = new float[16]; private float[] MATRIX_PROJECTION = new float[16]; private float[] MATRIX_VP = new float[16]; in "onSurfaceChanged": ... //Set ...
user1993006's user avatar
24 votes
4 answers
44k views

duplicate vector into matrix r

Wondering how to duplicate a vector into a matrix in R. For example v = 1:10 dup = duplicate(V,2) where dup looks like rbind(1:10,1:10). Thanks
Michael's user avatar
  • 7,257
4 votes
2 answers
36k views

Python: Transformation Matrix

Is this the correct way to co-compute translation and rotation, or is there a better way? At the moment my code translates and then rotates, could that pose a problem? Code from math import cos, sin,...
Mr. Polywhirl's user avatar
0 votes
2 answers
4k views

C++ Memory allocation. Matrix

I looked into two different method to allocate memory for the elements of a matrix Method n.1 int** matrix = new int*[rows]; for (int i = 0; i < rows; ++i) matrix[i] = new int[cols]; Method ...
doplumi's user avatar
  • 2,978
3 votes
2 answers
589 views

Singular value decomposition

I started to learn something about camera matrix and its solution method. There are some methods which in many of them I saw using of singular value decomposition of a matrix but I can't understand ...
Mehdi Bahar's user avatar
3 votes
1 answer
892 views

plotting points from matrix on matlab

I have a matrix which shows me the posiions of a knight in a knights tour. I'm looking to find a way of firstly finding the numbers in order and outputting their positions e.g. on a smaller board X X=...
Tessa Danger Bamkin's user avatar
8 votes
3 answers
13k views

Generate a data set consisting of N=100 2-dimensional samples

How do I generate a data set consisting of N = 100 2-dimensional samples x = (x1,x2)T ∈ R2 drawn from a 2-dimensional Gaussian distribution, with mean µ = (1,1)T and covariance matrix Σ = (0.3 0.2 ...
pythonnewbie's user avatar
3 votes
3 answers
14k views

sum of multiplication of two columns of a matrix in R

I am generating a matrix in R using following, ncolumns = 3 nrows = 10 my.mat <- matrix(runif(ncolumns*nrows), ncol=ncolumns) This matrix indicates the co-ordinates of a point in 3D. How to ...
mrn's user avatar
  • 425
2 votes
2 answers
6k views

Storing different sized matrices into array in MATLAB

I have 5 matrices of different dimensions (n = 256, 512, 1024, 2048, and 4096) and I was wondering how I could store them in an array (which I could iterate through in a for loop later). I tried just ...
user avatar
0 votes
1 answer
1k views

How do we rotate a tetris piece counter clockwise?

I looked at the algorithm here for clockwise rotation, but I can't do it the other way around. So basically, for clockwise rotation, you need to multiply the transpose to a rotation matrix, but how do ...
prog's user avatar
  • 150
1 vote
1 answer
480 views

How to create a scipy matrix that is MxN where, M and N are decided by the user and the elements are fed one after the other?

I want to create a 2-d matrix of coordinates. I want the use to be able to decide the number of rows and columns, and the elements of the matrix when the program is run. I know how to do this using ...
Raj's user avatar
  • 45
4 votes
2 answers
9k views

How to get image matrix 2D using JavaScript / HTML5

are there any solution of converting any image to the 2d matrix using html5/js example picture.jpg -------be Converted to -----> matrice[W][H] of pixels
AHmedRef's user avatar
  • 2,591
0 votes
1 answer
1k views

how to to process result of google distance matrix api further?

i am new to programming.. i have this code which gives distance between two points but need to further multiply it by an integer say 10.. the project i am working on is abt calculating distance ...
Sachin Tanwar's user avatar
2 votes
2 answers
3k views

how to access array elements using double pointer in c

It puts on the screen the last 2 numbers and other 2 strange numbers. How can I print all elements? I tried to keep the beginning of the double pointer **fool in another pointer **st. But it seems it ...
gia's user avatar
  • 25
6 votes
2 answers
2k views

Matlab + CUDA slow in solving matrix-vector equation A*x=B

I am calculating an equation A*x=B, where A is a matrix and B is a vector, x is answer (unknown) vector. Hardware specs: Intel i7 3630QM (4 cores), nVidia GeForce GT 640M (384 CUDA cores) Here's an ...
Aurimas Šimkus's user avatar
1 vote
1 answer
1k views

how to find the integral of a matrix exponential in python

I have a matrix of the form, say e^(Ax) where A is a square matrix. How can I integrate it from a given value a to another value bso that the output is a corresponding array?
user2076206's user avatar
-2 votes
3 answers
1k views

How to auto-generate and assign variables corresponding to elements in a matrix?

I am working on a binary linear program problem. I am not really familiar with any computer language(just learned Java and C++ for a few months), but I may have to use computer anyway since the ...
Eric's user avatar
  • 2,685
2 votes
3 answers
5k views

Use index to name a matrix after a loop in R

Please excuse my naive question. I have a loop which returns in every step, a matrix b. I would like to save each matrix from each loop, under a different name depending on the iteration number. For ...
Danai C.'s user avatar
  • 125
0 votes
3 answers
1k views

Matlab Array removing zero value

I am new to MatLab and programming in general. I have been set the following problem: 4 players take part in a competition each person starts with 100 points. Each person randomly plays another ...
Stephen's user avatar
1 vote
1 answer
758 views

MATLAB how to vectorize this while loop

so the idea here is to read data into a matrix, and then make that matrix a square matrix by removing the excess column(s) or row(s), but vectorized, without using any loops at all and without using ...
user2074643's user avatar
9 votes
1 answer
42k views

column vectors to matrix in R

I have a set of vectors V_1, V_2, ..., V_n that I would like to convert to a matrix. Each vector becomes a column vector in the matrix. The size of each vector is the same. Is there a simple function ...
CodeKingPlusPlus's user avatar

1
729 730
731
732 733
824