Most voted "matrix" questions
An array is a collection of variables of the same type, accessible with a single name and stored contiguously in memory. The individualization of each variable of a vector is done through the use of indexes. Vectors are matrices of a single dimension.
Learn more…508 questions
Sort by count of
-
0
votes1
answer1856
viewsCount rows and null columns of a matrix
Guys, help me on the following question: Write a complete program in C language that declares a square matrix of size 5x5. Then your program must fill this matrix randomly with 0s and 1s (the matrix…
-
0
votes1
answer292
viewsProblem with vector function in C++
Hello, I’m trying to make a matrix calculator and my idea would be that the user entered with the number of rows, columns and soon after with the matrix elements, the problem is that when I write…
-
0
votes1
answer104
viewsHow to transform a list that will be given at the input into a matrix?
I’m trying to turn this list that was given to me at the entrance into a matrix u l i o a e a p b e a r y l s j i t u a e e h u b e u o r r c t n e p b i o s b This is one of the input examples, my…
-
0
votes2
answers297
viewsHow to find the most common value within each column of an array using python?
I have a matrix (3 x 3280), I need to go through each column and consequently each row and find the most frequent value and thus generate another vector (1 x 3280) with these values. For example:…
-
0
votes2
answers1192
viewsPython matrices - Concatenate
Hello, I have two matrices and I would like to concatenate them, that is, put in a third matrix the matrices A and B one next to the other, in case form a matrix 3x6, but using a loop (command…
-
0
votes1
answer543
viewsTake only equal elements in a matrix
I have a matrix for example: 1 4 7 1 3 4 6 7 1 2 3 4 5 6 I have to see the repeating numbers in ALL lines, in the example, the numbers should be the result: 1 and 4. For it is they who repeat in all…
-
0
votes2
answers71
viewsMatrix in dynamic allocation with execution failure
Hello! The following code compiled, but shows error in execution: #include <stdlib.h> #include <stdio.h> #include <conio.h> typedef struct { char *nome; int valor; int peso; }…
-
0
votes1
answer247
viewsReceive a string from a PHP array for a Javascript variable?
I have a PHP array with a certain string, Ex.: $matriz[2][2] = "texto"`. Hence I want to pass this matrix to a Javascript variable. Ex.: `var v_php = "<?php echo $matriz[2][2]; ?>";` When I…
-
0
votes0
answers131
viewsTwo-dimensional Matrix in C
I have a record of products in C. Products can have up to 30 characters (columns), but can be infinite in quantity (rows). In the variable declaration, I used: char products[][30]; but when…
-
0
votes1
answer697
viewsHow to find the highest value of a matrix?
Well, I have a 3x4 matrix and I want to know how to develop a python code to get the highest value of this matrix. My code made so far was this: LINHAS = 3 COLUNAS = 4 LINHA_ MatrizM = [] for i in…
-
0
votes1
answer1201
viewsHow to return the data processing in Matrix passed as parameter for routines in VBA/Excel?
I need to pass separate matrices for a routine that sorts its elements and receive other treatments, and after that I want it to return those ordered and treated values to the original matrix; for…
-
0
votes1
answer87
viewsRead a specific phrase from a file and stop at it
I want to store in a string a part of an archive: Bruno Mossa Rezende 5 2 7 6 22 22 0.13 8 19 141 0.17 260 2 320 5.42 43 22 6 0.90 0 0 0 5 of that file I want to store in a string "Bruno Mossa…
-
0
votes2
answers477
views -
0
votes1
answer89
viewsSmallest element of a sub-list, in a list
I’m trying to apply heuristics to a code that I’ve been working on, but I need to get the smallest element from a sub-list, from a list. example: L = [[1, 1, 6], [1, 2, 5], [1, 3, 7], [2, 1, 1], [2,…
-
0
votes0
answers20
viewsCoordinate counting in MATLAB
Hello. I have an 8x2 matrix: M = [1 2; 5 8; 3 1; 6 6; 7 1; 1 2; 3 1; 7 1]; I would like to count how many times each line (x,y) repeats. The result should be, for example, like this: Trying:…
-
0
votes1
answer54
viewsNullpointerexception when comparing two String arrays in java
I have two String matrices and when executing this: if (prod[i][0].equals(temporaria[j][0]) && prod[i][0]!= null && temporaria[j][0]!= null) get Nullpointerexception without at least…
-
0
votes1
answer1089
viewsCalculate distance between two indexes of a matrix?
I want to enter two matrix indexes, and subtract that value. For example I want to enter with index [0, 1] and [2, 10]. And then I want to subtract the value, to calculate the distance I’m between…
-
0
votes1
answer543
viewsProblem with float and matrix
I have to add the values that have two or more decimals but when I put by Exp: "1.0", it fills this whole row automatically and jumps to the next, I reviewed and I don’t know why you are giving…
-
0
votes1
answer99
viewsPrint multiple matrices separately
I wonder if you have how to print these three matrices without having to create several for's, the printing of the same on the screen should be separated. ( I need an alternative because I have…
-
0
votes0
answers143
viewsDelphi Datamatrix Static size
I am working with Data Matrix I am using the Unit Datamatrixbarcode, dmtx. var options:DatamatrixEncodeOptions; options := InitializeDatamatrixEncodeOptions; options.moduleSize := 4;…
-
0
votes5
answers1043
viewsMatrix Nxm (2D) in Python with Numpy
I’m trying to solve a college activity, but I couldn’t transpose the logic into the code. The case is as follows: "The user will enter two integers. These integers will determine the size of the…
-
0
votes1
answer627
viewsHow to save information to an array?
Java masters, I am learning about matrices, vectors and I would like to know what happens to my code, because I create a matrix to receive six names and six positions for the employees matrix. Only…
-
0
votes0
answers118
viewsSegmentation fault (core dumped) in matrix data scanf
This following piece of error code, does not read user data to allocate in 5x2 matrix, can not find the problem int linha=0, coluna=0; int matriz[5][2]; for(linha=0;linha < 5; linha++){…
-
0
votes1
answer877
viewsRead text file picking float numbers and playing in matrix
I have a text file for example with: v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v…
-
0
votes1
answer33
viewsKnow when a file row starts with a given string
I have a file like this: # Blender v2.69 (sub 0) OBJ File: 'CUBO.blend' # www.blender.org mtllib cube.mtl o Cube.022_Cube.030 v 0.450000 -1.450000 0.550000 v 0.450000 -1.450000 1.450000 v -0.450000…
-
0
votes1
answer2690
viewsProgram Received Signal sigsegv Segmentation fault
I made the code in C of the statement: Develop a program that simulates a ticketing system for a airline. The company has no flights, where in each of them there are a available seats. The first m/2…
-
0
votes1
answer5357
viewsMultiplication of matrices in Python
Hello, I’m making a python algorithm that makes the product between two matrices, but I’m having trouble displaying the resulting matrix matriz = [] linha = [] linha2= [] matriz_result = [] result =…
-
0
votes2
answers201
viewsMatrix in python
I’m building a matrix in python, but I can’t make the right impression. Someone could help me. Follow the code: linhas = 4 entrada = input() valor = entrada.split() matriz = [] while (entrada !=…
-
0
votes0
answers29
viewsTraverse a multidimensional vector and capture existing value
How to go through these vectors "$_SESSION['gatos1']" and when he finds a value equal to "$idt" it returned me the values contained within the vector that contains the value equal to the "$idt".…
-
0
votes1
answer2019
viewsSum the diagonals of a matrix
I need to do a program that takes out the diagonals of a matrix. As an example But I’m having a hard time. Follows code: #include <stdio.h> #include <math.h> #define M 4 #define N 3 int…
-
0
votes1
answer3879
viewsHow do I determine a square matrix in python?
My file is like this: arq = open('matriz.txt', 'r') texto = [] matriz = [] texto = arq.readlines() for i in range(len(texto)): matriz.append(texto[i].split()) for i in range(len(texto)):…
-
0
votes1
answer114
viewsmatrix product using struct
I used struct to store number of rows and columns of the matrix. I make the product of two matrices and the product of a matrix with a vector, but the output is always 0. I do not know how to change…
-
0
votes1
answer278
viewsIn R, how to find out if two vertices are adjacent from an adjacency matrix
This is the adjacency matrix, how to find out (implement an algorithm) if the vertices 2 and 3 are adjacent using R?…
-
0
votes2
answers343
viewsCheck equal values in an Array and add them
Hello. I have the following senary: I have an array of objects as below. var project = [ {partNumber: 1234, project: X19, gap: 30}, {partNumber: 1234, project: X19, gap: 40}, {partNumber: 5678,…
-
0
votes0
answers188
viewsstruct that stores the number of rows and columns of the matrix and of a vector
I used a struct to store the number of rows (m) and columns (n) of the matrix and another to store the number of columns of the vector (n). I make the product of two matrices in function prod() and…
-
0
votes1
answer1079
viewsCompare integer and pointer
Well, I have a question, I’m trying to copy a line to a file but there’s an error that says I can’t compare an integer to a Pointer, can anyone help me? The error is on the line ch = getc(file1);…
-
0
votes2
answers3167
viewsOperations with C++ matrices
To perform the sum of items of a matrix (primary diagonal and secondary diagonal) I was able to write the following code. Can someone help me dry up the code? so I can compare the codes... C++: And…
-
0
votes1
answer663
viewsPassing pointer pointer by reference
I’m making a program where I need to dynamically allocate two matrices, so I thought I’d make this allocation into a function. I tried to do it this way, but it’s giving "Segmentation Failure".…
-
0
votes2
answers526
viewsApply a function to each element of a python matrix
I need to apply a lambda function to all elements of a matrix in and it returns a matrix of the same size type like this: i have the matrix mat in numpy style: mat = array[[1, 2, 3], [4, 5, 6]] and…
-
0
votes1
answer45
viewsIdentifying the most effective method of identifying the central element of a matrix
I have the following algorithm: import numpy as np matriz = np.array(np.zeros(81).reshape(9, 9)) for i in range(1, matriz.shape[0], 3): for j in range(1, matriz.shape[1], 3): matriz[i, j] = 255…
-
0
votes1
answer109
viewsGet values from a list and column
I’m having trouble with a check, I have a certain matrix with N rows and N columns, I need to go through it and know in which row and column have only odd numbers. Go as far as I can go. matriz =…
-
0
votes1
answer361
viewsHow to mount an array in python with undefined value of i and j
i am beginner in python and I am in doubt in matrix mounting. In case I did the following: import numpy as np n=3 A = np.zeros((n*n,n*n)) j= 2 i = 2 k = i+n*(j-1) a = -4 L1 = i-1+n*(j-1) a1 = 1 L2 =…
-
0
votes0
answers1019
viewsReturn a matrix of a function in C
Hello, I am doing a program in C that requires to be modularized, that the user registers the desired courses, prints on the screen the courses,but I want to use the matrix of courses, in another…
-
0
votes1
answer60
viewsHow to read keyboard data to an array in Java?
I’m trying to pass the data inside the matrix, but it’s not running the lines. int i=0; int j=0; for(;i<3;i++){ for(;j<4;j++){ System.out.println("Valor para a posição ["+i+","+j+"]");…
-
0
votes2
answers313
viewsFill list and finish python loop
I need help on a problem that asks me to fill in by adding data to a list until it is declared 'end'. E=[] i=0 E.append(input('Nome do elemento?')) while (i!=fim): E.append(input('Nome do…
-
0
votes1
answer86
viewsMatrix input reading in python
I’m wondering how to create an array in python, but the input would be the whole matrix. I tried to make: matrix=[] for r in range(5): row=[] for c in range(5): row.append(input().split())…
-
0
votes0
answers723
viewsCheck neighbor in a matrix
I have the following problem: I have a large matrix [10x10 for example] It has values from 1 to 9. I must check whether a vector [1, 2, 3, 4, 5] (for example) is contained in this matrix. When…
-
0
votes1
answer697
viewsPassing matrix to function by reference
Good morning everyone, I wish in my code to leave the Main(); only with calling functions, all work is divided into small functions in the document. I want to write a matrix[3][3] in a function and…
-
0
votes2
answers43
viewsHow can I turn a string of numbers into a Matrix?
I’m doing an exercise where I should extract rows and columns from a string, creating an array. Input let str = '1 2 3\n4 5 6\n7 8 9', I wrote a code that returns: [ '4 5 6' ], but I’d like him to…
-
0
votes1
answer1550
viewsAdd row and column values and store in vector
Good afternoon, I am making an algorithm in which I need to store the total sums of each row and each column in different vectors. For example: vector A of 5 positions receives the sum total of 5…