matrix

how to generate a random binary matrix with a specific condition in matlab?

◇◆丶佛笑我妖孽 提交于 2019-12-25 18:22:12
问题 If matrix A shows the number of group of ones in G (n,m) matrix like that G = [ 1 1 0 0 1 0 1 1 1 0 1 0 1 1 1 ] so the A matrix will be A = [ 2 1 3 0 1 3 ] Then i want to generate (n,m) random matrix which the ones in this Matrix depend on A in the same order they appear one solution will be x = [ 0 1 1 0 1 0 0 1 1 1 1 0 1 1 1 ] another solution x = [ 1 1 0 1 0 1 1 1 0 0 1 0 1 1 1 ] 回答1: As mentions in comments to the OP, StackOverflow is not a code-writing service. Having said that, this was

How to identify lat and long for a global matrix?

坚强是说给别人听的谎言 提交于 2019-12-25 18:13:03
问题 I am going to use a binary files (climate variable for the globe ) that can be downloaded from here: ftp://sidads.colorado.edu/pub/DATASETS/nsidc0301_amsre_ease_grid_tbs/global/ This file is a binary (matrix) file with 586 lines and 1383 columns (global map). I would like to extract a value that is at 100 longitude and 50 latitude . I can extract any point using x and y using: X<-450 ; Y<-145 extract<-vector() file<- readBin(conne, integer(), size=2, n=586*1383, signed=T) file2<-t(t(matrix

How to identify lat and long for a global matrix?

守給你的承諾、 提交于 2019-12-25 18:12:19
问题 I am going to use a binary files (climate variable for the globe ) that can be downloaded from here: ftp://sidads.colorado.edu/pub/DATASETS/nsidc0301_amsre_ease_grid_tbs/global/ This file is a binary (matrix) file with 586 lines and 1383 columns (global map). I would like to extract a value that is at 100 longitude and 50 latitude . I can extract any point using x and y using: X<-450 ; Y<-145 extract<-vector() file<- readBin(conne, integer(), size=2, n=586*1383, signed=T) file2<-t(t(matrix

Is there a Boost (or other common lib) type for matrices with string keys?

試著忘記壹切 提交于 2019-12-25 17:45:09
问题 I have a dense matrix where the indices correspond to genes. While gene identifiers are often integers, they are not contiguous integers. They could be strings instead, too. I suppose I could use a boost sparse matrix of some sort with integer keys, and it wouldn't matter if they're contiguous. Or would this still occupy a great deal of space, particularly if some genes have identifiers that are nine digits? Further, I am concerned that sparse storage is not appropriate, since this is an all

Creating a colormap (matlab) with 30 colors

。_饼干妹妹 提交于 2019-12-25 17:39:52
问题 I am having trouble writing a script that will show shades of green and blue. A colormap needs to be created that has 30 colors (10 blue, 10 aqua, 10 green) In the image the blues will be in the first row, aquas in the second, and green in the third. I am using Matlab and I shouldn't use loops. colors = [0.2 0.1 0.5; 0.1 .5 0.8; 0.2 0.7 0.6; 0.8 0.7 0.3; 0.9 1 0]; colormap(winter) vec = 1:length(colors); image(vec) 回答1: %this script will show shades of green and blue colors = zeros(3,10,3);

Creating a colormap (matlab) with 30 colors

瘦欲@ 提交于 2019-12-25 17:38:07
问题 I am having trouble writing a script that will show shades of green and blue. A colormap needs to be created that has 30 colors (10 blue, 10 aqua, 10 green) In the image the blues will be in the first row, aquas in the second, and green in the third. I am using Matlab and I shouldn't use loops. colors = [0.2 0.1 0.5; 0.1 .5 0.8; 0.2 0.7 0.6; 0.8 0.7 0.3; 0.9 1 0]; colormap(winter) vec = 1:length(colors); image(vec) 回答1: %this script will show shades of green and blue colors = zeros(3,10,3);

Comma separated Matrix from txt files - continued

不打扰是莪最后的温柔 提交于 2019-12-25 17:20:57
问题 I need to form a matrix from a list of textfiles containing frequency distribution of expressions. Therefore, I created a list of all that text files (lof) from a directory and used it to build a matrix (thanks to gboffy). Each filename in that list is structured in a way: CompanyName-SerialNumber_IssueDate_IFRS.txt (Example: GoldmanSachs-123456_31.12.2014_IFRS.txt). Each file's content is structured in a exact same way too: CompanyABC-123456_31.12.2012_IFRS.txt Company ABC-123456_31.12.2012

Comma separated Matrix from txt files - continued

牧云@^-^@ 提交于 2019-12-25 17:20:48
问题 I need to form a matrix from a list of textfiles containing frequency distribution of expressions. Therefore, I created a list of all that text files (lof) from a directory and used it to build a matrix (thanks to gboffy). Each filename in that list is structured in a way: CompanyName-SerialNumber_IssueDate_IFRS.txt (Example: GoldmanSachs-123456_31.12.2014_IFRS.txt). Each file's content is structured in a exact same way too: CompanyABC-123456_31.12.2012_IFRS.txt Company ABC-123456_31.12.2012

determining the sum of top-left to bottom-right diagonal values in a matrix with Ruby?

自闭症网瘾萝莉.ら 提交于 2019-12-25 17:18:22
问题 I have a square matrix of indeterminate row & column length (assume rows and columns are equal as befits a square). I've plotted out an example matrix as follows: matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] My goal is to get a sum from top-left to bottom-right of the diagonal values. Obviously in this example, this is all i'll need: diagsum = matrix[0][0]+matrix[1][1]+matrix[2][2] #=> 15 I see the pattern where it's a +1 incremental for each row & column argument in the matrix, so the code i

Swapping two rows in a matrix

橙三吉。 提交于 2019-12-25 17:08:50
问题 I am having a problem in swapping two rows in a matrix that is a 2D-dynamic array. I wanted to know if there is a function to use directly or if there is none I would like to know how to make one. Thanks in advance. Here is how I made the dynamic array: int **ptrMatrix = new int*[row]; for (int i = 0; i < row; i++) ptrMatrix[i] = new int[column]; 回答1: I found the solution ... it is done simply by making a temporary variable (X) and appling the following code for (int i=0;i<columns;i++) { X