m= magic(4)
disp(m)
s1 = m(1:half);
s2 = m(half + 1 : end);
x=zeros(s1);
C = s2.^2;
A=[x,c];
disp(A)
Given a matrix M (any matrix entries any size): Given matrix M, whit an even number...
Given a 2d matrix of size N x M (which must be read from a file provided to you), transpose it into a M x N matrix where N is the number of rows and M is the number of columns. void transpose(int n, int m, const int A[n][m], int AT[m][n]); Write a main() program to test and demonstrate your function. Show your function works for, at minimum, 3x6 and 10x6 matrices.
Theory: A vector with nonnegative entries is called a probability vector if the sum of its entries is 1. A square matrix is called right stochastic matrix if its rows are probability vectors; a square matrix is called a left stochastic matrix if its columns are probability vectors; and a square matrix is called a doubly stochastic matrix if both the rows and the columns are probability vectors. **Write a MATLAB function function [S1,S2,P]=stochastic(A) which accepts a square matrix A...
Let A be a matrix of size m xn. Show that AAT and AT A are both square matrices (equal number of rows and columns) (10 pts) If A is mXn then A is nXm so AA must have size mXm Similarly, A" A must be nxn
In C++ Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position. If A is a matrix of five rows and six columns, we say that the matrix A is of the size 5 X 6 and sometimes denote it as Asxc. Clearly, a convenient place to store a matrix is in a two-dimensional array. Two...
1. Write a MATLAB function that takes a matrix, a row number and a scalar as arguments and multiplies each element of the row of the matrix by the scalar returning the updated matrix. 2. Write a MATLAB function that takes a matrix, two row numbers and a scalar as arguments and returns a matrix with a linear combination of the rows. For example, if the rows passed to the function were i and j and the scalar was m,...
Given a matrix with m rows and n columns, m adjacent numbers are chosen from m rows, where two numbers are adjacent to each other if they are directly connected vertically or diagonally and only one number is taken from one row. Design a dynamic programming algorithm to find the smallest sum of these m numbers. For example, given a 3 by 3 matrix 1 2 3 4 5 6 7 0 2 The sum of three numbers 1, 4,...
Question A matrix of dimensions m × n (an m-by-n matrix) is an ordered collection of m × n elements. which are called eernents (or components). The elements of an (m × n)-dimensional matrix A are denoted as a,, where 1im and1 S, symbolically, written as, A-a(1,1) S (i.j) S(m, ). Written in the familiar notation: 01,1 am Gm,n A3×3matrix The horizontal and vertical lines of entries in a matrix are called rows and columns, respectively A matrix with the...
Write a function called ''minandmax'' . Function ''minandmax'' takes only one input argument that is a matrix M . This matrix M can be any size (any number of columns and rows) with any random integer values . Function ''minandmax'' returns two output arguments. The first output argument is called ''difference_row'' that returns a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. The second output argument is called ''difference_all''...
Diagonal Difference HackerRank Pseudocode and C++: Given a square matrix, calculate the absolute difference between the sums of its diagonals. Function Description Complete the diagonalDifference function described below to calculate the absolute difference between diagonal sums. diagonalDifference( integer: a_size_rows, integer: a_size_cols, integer array: arr) Parameters: a_size_rows: number of rows in array a_size_cols: number of columns in array a: array of integers to process Returns: integer value that was calculated Constraints -100 < = elements of the matrix < = 100...
The picture is given in a PPM file and your program should put the converted one into another PPM file. •Use argv[1] for the given file and argv[2] for the converted file.In addition, you can use a temporary file called tmp.ppm. •The number of rows and columns are not fixed numbers. •The converted file should also follow the PPM format with the above simplification, and can be converted subsequently. •Read the pixel matrix into a buffer. •For each row i(...