[Solved] How do i select a number in a matrix in c?

If you mean number in a matrix as follows (example for matrixSize == 4): 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 you can just calculate indexes from number matrixValues[number/matrixSize][number%matrixSize] EDIT: For case when your 2D arreay defined as int matrixValues[matrixSize][matrixSize]; All elements allocated in memory sequentially, … Read more

[Solved] Error using .* Matrix dimensions must agree?

As your input image I is a color image (RGB), the array I is three-dimensional: width-by-height-by-3, because for each pixel you need three values: red, green and blue. The output of butterhp, however, is always width-by-height, so you are trying to multiply a 2D-array times a 3D-array, which fails of course. Often, processing in grayscale … Read more

[Solved] Whats wrong with the c code?

A 2D array does not decay to a pointer to a pointer. By using: maxim=findMax((int **)a,m,n); you are forcing the compiler to ignore your error. Instead of int findMax(int **a,int m,int n) use int findMax(int a[][20],int m,int n) and then, call the function simply using: maxim=findMax(a,m,n); You said: The problem statement says that int findMax(int … Read more

[Solved] Passing to a same function matrices with different sizes of both dimensions

You should use a typedef so that you don’t have to use any awful syntax: using matrix_t = int[3][3]; And you should pass your args by reference whenever possible: void handle_matrix(const matrix_t &mat){ // do something with ‘mat’ } If you want to use the original syntax without a typedef: void handle_matrix(const int (&mat)[3][3]){ // … Read more

[Solved] How to set a matrix as a parameter to a function

You can represent the matrix as a vector<vector<int> >. Try something like this: #include <vector> using namespace std; void myFunction(const vector<vector<int> >& matrix) { // do something w/ matrix passed in… } int main() { // create a 3×4 matrix initialized to all zero const size_t rowCount = 3; const size_t colCount = 4; vector<vector<int> … Read more

[Solved] How to add a value in a matrix and make it decrease in radial way? [closed]

[EDIT] So based on you’re edit i thought this solution. Since you don’t specify any programming language i’ll use some c-like functional programming. I’ll leave you the work of transforming it to object oriented if you need it. Input: Global maxtrix that starts in M[0,0] and ends in M[100’000, 100’000] (Note that, to make it … Read more