## [Solved] How to shrink at runtime a struct matrix (using realloc() for example)

You should reduce the number of columsn, not rows. Not mat1 but mat1->array should be reallocated. Not nrow and ncol (not updated) but mat1->nrows and mat1->ncols (updated) should be used for the new size. The elements are size_t, so allocating for int mayn’t be enough. Using the variable for calculating size is safe. In the … Read more

## [Solved] in c++ how to shows result of matrix with the additions [closed]

You need a method to add void add(int a[][maxCols], int b[][maxCols], int res[][maxCols]) { int row, col; for (row = 0; row < maxRows; row++) { for (col = 0; col < maxCols; col++) { res[row][col] = a[row][col] + b[row][col]; } } } and create 2 matrix in main, add them and show the result: … Read more

## [Solved] Given a binary matrix of 0 and 1. Find the longest sequence of 1’s either row wise or column wise

var max_1_row = -1; var row_num = -1 var max_1_col = -1; var col_num = -1 for (var i = 0; i < rows; i++) { var max_1_in_row = 0; var max_1_in_row_seq = 0; var max_1_in_col = 0; var max_1_in_col_seq = 0; for (var j = 0; j < cols; j++) { if (arr[i][j] == … Read more

## [Solved] Matlab, get the peaks in a vector, this does not work: max_locations = find(A==max(A)) [duplicate]

Because the values at other locations are not maximum: 162 instead of 163. >> L([31 57 83 109 135]) ans = 163 162 162 162 162 If you want to find some extreme pickes you can try; >> pick_location = find(L>160) pick_location = 31 57 83 109 135 136 To actually find peaks try PEAKFINDER … Read more

## [Solved] How to sort the column of a 2d vector? [closed]

The issue is that for each iteration of the for loop, the std::sort can potentially change the already sorted column. For example, if you sort column i, then columns i-1, i-2, etc. can lose the changes that were made to sort those columns. Without changing too much of your original code, and albeit not the … Read more

## [Solved] Matrix Scale down using MATLAB [closed]

You cannot have non-integer sized matrices. 22,5 is not a valid dimension of a matrix. If you are talking about images you can resize the matrix in Matlab using imresize. . A = rand(254, 128); A = imresize(A, [45, 23]); 5 solved Matrix Scale down using MATLAB [closed]

## [Solved] Browse a matrix

Here the solution I found : private static IEnumerable<int> ComputeMatrix(int[,] matrix) { // check args if (matrix.Rank != 2) { throw new ArgumentException(“matrix should have a rank of 2”); } if (matrix.GetUpperBound(0) != matrix.GetUpperBound(1)) { throw new ArgumentException(“matrix should have the same size”);} // indice treated List<int> treatedIndex = new List<int>(); for (int i = … Read more

## [Solved] C# Console Application program to Create a user defined matrix and find Lowest number [closed]

Put this outside your “main” method to get make sure the user gives a number. private static int GetNumber(string request) { bool succeeded = false; Console.WriteLine(request); string reply=””; while(!succeeded) { reply = Console.ReadLine(); try { int.Parse(reply);//Attempt to convert “reply” into an integer. succeeded = true; } catch { Console.WriteLine(request+” (make it a number)”); } } … Read more

## [Solved] Processing the data in a matrix in r [closed]

NOTE: Your question as it stands is not appropriate for this site. You should include a minimum reproducible example. Include code that you’ve tried and where it’s causing you trouble. At this point, you’re likely to continue getting down votes, and your question may potentially get closed. Be aware of that. Please visit the help … Read more

## [Solved] c program to print min number of days required to spread rumour in matrix [closed]

The fastest way that the rumour will travel is when the roumor starts in the middle of the matrix. Since it travels only horizontally or vertically, if it starts from the middle then it will take m/2 + n/2 days to reach a corner in the worst case. Just try this printf(“%d\n”,m/2+n/2); it should work. … Read more

## [Solved] can’t multiply matrix and list which type ‘float’

You are multiplying a list by a float. You should multiply each row of the matrix with words. Something like this will work. multiply_nonspam_test = [] for row in transpose_test_feature: multiply_nonspam_test.append([x*y for x,y in zip(row, log_train_probs_nonspam_words)]) print multiply_nonspam_test 0 solved can’t multiply matrix and list which type ‘float’

## [Solved] Convert Matrix to Vector [closed]

Your problem is a very specific one. I don’t see how this will be of any use to anybody but yourself. There is no ‘one line solution’. There are many ways to approach indexing problems, I like to use scalar indexing when possible: Ncolumns = size(Matrix,1); Nblocks = floor(Ncolumns/4); %number of 4-line blocks (excluding the … Read more

## [Solved] Convert text file to matrix [closed]

I will try to guess what is asked. Assuming that your data frame is named df, you can convert each column to matrix and put it in list using lapply(). For example, I converted to matrix with two columns. seq_len(ncol(df) will make sequence of numbers from 1 to number of columns, so conversion will iterate … Read more

## [Solved] Convert text file to matrix [closed]

Introduction This post provides a solution to the problem of converting a text file into a matrix. The solution involves using a combination of programming languages such as Python, R, and MATLAB to read the text file and then convert it into a matrix. The post also provides a step-by-step guide on how to do … Read more

## [Solved] Finding subsets of a set of vectors that fulfill some conditions

The question is a bit complicated and hard to follow.. Anyways I tried writing some code to the best of my understanding of the problem. Here is the part that finds the possible combinations: % input matrix A=[1 2 0 1 2 0 0 0 2 1 1 1 0 2 2 0 3 0 … Read more