matrix

sum only the negative values in a row from an xts-object

风流意气都作罢 提交于 2020-01-06 07:29:11
问题 I have an xts-object and I want to sum only the negative values in the first row. The code sum(test[test<0]) gives me the error Error in `[.xts`(test, test < 0) : 'i' or 'j' out of range but sum(test[1],na.rm=TRUE) works, but then I have the sum of all the values, not just the negative ones: [1] -0.9786889 Without giving an example of data yet, does anybody know why this simple code doesnt work? The dimension of the xts-object is > dim(test) is 216 39 . 回答1: There is a chance that this is

generate plot matrix from two different matrices in matlab [duplicate]

左心房为你撑大大i 提交于 2020-01-06 07:01:52
问题 This question already has an answer here : Create a larger matrix in special case [closed] (1 answer) Closed 6 years ago . I have two matrices (5_by_1), say A=[5 rows,1 column] and B=[5 rows, 1 column] if I do plot(A,B), I will create a large matrix C=[5 rows,5 columns] wright?! Now I would like to create this large matrix without plot it. I want this matrix directly. thank you. For example A=[1 2 3 4 5 ] and B=[3 4 2 1 4] c= 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 回答1: This should work: a =

generate plot matrix from two different matrices in matlab [duplicate]

前提是你 提交于 2020-01-06 07:01:09
问题 This question already has an answer here : Create a larger matrix in special case [closed] (1 answer) Closed 6 years ago . I have two matrices (5_by_1), say A=[5 rows,1 column] and B=[5 rows, 1 column] if I do plot(A,B), I will create a large matrix C=[5 rows,5 columns] wright?! Now I would like to create this large matrix without plot it. I want this matrix directly. thank you. For example A=[1 2 3 4 5 ] and B=[3 4 2 1 4] c= 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 回答1: This should work: a =

Resolve matrix differential equation with sparse matrix and ojAlgo

ぐ巨炮叔叔 提交于 2020-01-06 06:42:28
问题 I am developping a java evolution tool with ojAlgo, and I try to resolve the following equation : where A is a sparse matrix (for now the dimension of the matrix is 2000 x 2000, it will be scaled later on), A is not symmetric and use only real values. I made some researchs and I tried to find the way to resolve this equation (using SparseStore) on github wiki/javadoc but I didn't find a way to do it. Can you help me find methods/class I should use ? Thank you 回答1: There is no direct/specific

How to apply a function on every pair of rows of a Matrix in Matlab?

萝らか妹 提交于 2020-01-06 06:25:11
问题 I'm new to matlab and working with matrix and I'm kinda confused. I'm supposed to make a m x n matrix called M and it's elements are -1 , 1 and 0 . I need to write a function called d(x,y) which returns 1 if x = -1 and y = 1 . And returns 0 otherwise. and another function which calculates the sum of d(m(i,j),m(k,j)) in every column: Please read the comment for an example. How to find the sum? I know basic programming but I don't know how to do this. 回答1: You can use nchoosek for selction:

2d Array Store values as matrix format Java

这一生的挚爱 提交于 2020-01-06 06:01:28
问题 i have this array here that cfreates a 7x7 matrix using random strings when i try to get the value of the array the values print in a line format when i use pritnln the matrix is create I need to store the values of println in a variable or rearange the array so that the values are in a matrix format. Random rand = new Random(); String[][] debug_board_state = new String[7][7]; setCurrentState(new State(WIDTH_EASY)); for (int row = 0; row < debug_board_state.length; row++) { for (int column =

performance of fortran matrix operations

旧时模样 提交于 2020-01-06 05:49:07
问题 I need to use Fortran instead of C somewhere and I am very new to Fortran. I am trying to do some big calculations but it is quite slow comparing to C (maybe 10x or more and I am using Intel's compilers for both). I think the reason is Fortran keeps the matrix in column major format, and I am trying to do operations like sum(matrix(i, j, :)), because it is column major, probably this uses the cache very inefficiently (probably not using at all). However, I am not sure if this is the actual

Auto-fill matrix without row-repetitions

我与影子孤独终老i 提交于 2020-01-06 05:10:06
问题 I have a series of numbers: test = [1 1 1 2 2 2 3 3 3 4 4 4 5 5 5] which I want to randomely fill into a 3x5 matrix without having the same number in the same row. How can I do this in matlab? Potentially I could randomize the test vector and fill it into the 5x3 matrix but I don't know how to do this without getting the same number in the same row. 回答1: If you want to fill a 3-by-5 matrix with all of the values in test , making sure each row has no repeated values, you can do this very

How to replace the NULL values in a pivot output with zeroes?

南楼画角 提交于 2020-01-06 05:02:47
问题 Following the answer from a previous question I want to get rid of some NULL values when I do not have a number for some cases I have the following query CREATE TABLE [MYTABLE] ( [A] int , [B] int , [VAL] float ); INSERT INTO [MYTABLE] ([A], [B], [VAL]) VALUES (1, 1, -218.46), (1, 2, -2.1846000000000e+02), (2, 1, 6.4000000000000e+01), (2, 2, -218.46), (2, 3, 6.4000000000000e+01), (3, 2, -2.1846000000000e+02), (3, 3, -218.46), (4, 3, 6.4000000000000e+01), (4, 4, -218.46), (4, 5, 6

how to get setScaleType(ImageView.ScaleType.FIT_CENTER) effect using setScaleType(ImageView.ScaleType.MATRIX)

做~自己de王妃 提交于 2020-01-06 05:01:11
问题 In Android using ImageView and Matrix, I want to scale an image to fit in the display area. Then using pinch, a user can zoom the image. Using setScaleType(ImageView.ScaleType.FIT_CENTER) I can fit my image in display area. But when I use setScaleType(ImageView.ScaleType.MATRIX) , to start zooming the image, the image gets reset to default size. So my question is how to find a scale matrix which will give same effect as setScaleType(ImageView.ScaleType.FIT_CENTER) . 回答1: You need to use