Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am just trying to get a matrix so it can order its rows based on first

ID: 3530640 • Letter: H

Question

Hello, I am just trying to get a matrix so it can order its rows based on first column, greatest absolute value goes first for example if i enter this matrix A=[2 2 2 ; -5 -5 -5 ; 10 10 10 ] the new matrix should be 10 10 10 -5 -5 -5 2 2 2 function[]= partialpivoting(enter_matrix_c) A= enter_matrix_c ; % finding the number of rows j=size(A,1) % finding the number of columns k=size(A,2) %taking the absolute value of first column A A= enter_matrix_c ; while(1) if max(abs(A(j, 1))) > max(abs(A((j-1),1))) A([(j-1) j],:)=A([j (j-1)],:) end end end

Explanation / Answer

FOLLOW THIS Matrices are two dimensional named data objects (Igor supports up to four dimensions.) You can perform basic arithmetic operations on matrices using standard data assignment statements. For example: Mat1= Mat2*Mat3 // element by element multiplication You can perform matrix multiplication and matrix dot product with a natural syntax using MatrixOP. For example: MatrixOp Mat1= Mat2 x Mat3 // matrix multiply The following example computes element by element multiplication of matrix A with matrix B from which we subtract the inverse of matrix C times the diagonal matrix created from the array D: MatrixOP res=A*B-Inv(D) x Diagonal(D) MatrixOP supports array based operations such as Fourier Transforms, Chirp-Z transforms, convolutions and correlations. For example, you can compute circular or acausal convolutions using cascaded transforms and array multiplications as in the following lines: MatrixOP/O circConvolution=IFFT(FFT(fx,0)*FFT(rect,0),0) MatrixOP/O acausalConvolution=IFFT(FFT(fx,0)*FFT(rect,0),4) Obviously you can get the same results using the more compact syntax: MatrixOP/O circConvolution2=Convolve(fx,rect,0) MatrixOP/O acausalConvolution2=Convolve(fx,rect,4) The following is a list of functions supported under MatrixOP: Abs() Returns the absolute value of a real number or the magnitude of a complex number. acos(z) Returns the arc cosine of the generic argument z. asin(z) Returns the arc sine of the generic argument z. asyncCorrelation(w) Returns the asynchronous spectrum correlation matrix for a real valued input matrix wave w. See also syncCorrelation. atan(z) Returns the arc tangent of the generic argument z. atan2(y,x) Returns the arc arc tangent of real y/x. beam(w3D,row,col) Returns a 1D array corresponding to the data in the beam defined by w3D [row ][col ][] (see also ImageTransform getBeam). The beam function belongs to a special class in that it does not operate layer by layer. It therefore does not permit compound expressions in place of any of its parameters. The beam function has the highest precedence. ceil(z) Returns the smallest integer larger than z. ChirpZ(data,A,W,M) Returns the Chirp Z Transform of the 1D wave data. ChirpZf(data,f1,f2,df) Returns the Chirp Z Transform except that the transform parameters are specified by real valued starting frequency f1, end frequency f2 and frequency resolution df. In this case the transform is confined to the unit circle because both A and W have unit magnitude. col(w,c ) Returns colum c from matrix wave w. Conj(matrixWave) Returns the complex conjugate of the input expression. convolve(w1,w2,opt) Returns the convolution of w1 with w2 subject to options opt. The dimensions of the result are determined by the largest dimensions of w1 and w2 with the number of rows padded (if necessary) so that they are even. Supported options include opt=0 for circular convolution and opt=4 for acausal convolution. correlate(w1,w2,opt) Returns the correlation of w1 with w2 subject to options opt. The dimensions of the result are determined by the largest dimensions of w1 and w2 with the number of rows padded (if necessary) so that they are even. Supported options include opt=0 for circular correlation and opt=4 for acausal correlation. cos(z) Returns the cosine of the generic argument z. Det(matrixA) returns a scalar corresponding to the determinant of matrixA, which must be real. Diagonal(wave1D) Creates a square matrix that has the same number of rows as wave1D. All entries are zero except for the diagonal elements for which the entries are taken from the first column in wave1D. Use DiagRC if the input is not an existing wave (such as a result from another function). DiagRC(waveA,rows,cols) Returns a 2D matrix of dimensions rows by cols. All matrix elements are set to zero except those of the diagonal which are filled sequentially from elements of waveA. The dimensionality of waveA is unimportant. If the total number of elements in waveA is less than the number of elements on the diagonal then all elements will be used and the remaining diagonal elements will be set to zero. equal(a,b) Returns unsigned byte result with 1 for equality and zero otherwise. The dimensionality of the result matches the dimensionality of the largest parameter. Either or both a or b can be constants (i.e., one row by one column). If a and b are not constants, they must have the same dimensions. Both parameters can be either real or complex. A comparison of a real with a complex parameter returns zero. exp(z) Returns the exponential function for a generic argument z, which can be real or complex, scalar or a matrix. FFT(inWave,options) Returns the FFT of inWave subject to the options field. inWave must have an even number of rows. The options field contains a binary field flag. Set the second bit to 1 if you want to disable the zero centering (see /Z flag in the FFT operation). Other bits are reserved. Note that MatrixOP does not support wave scaling and therefore it does not produce the same wave scaling changes as the FFT operation. floor(z) Returns the largest integer smaller than z. Frobenius(matWave) Returns the Frobenius norm of a matrix defined as the square root of the sum of the squared absolute values of all elements. greater(a,b) Returns an unsigned byte for the truth of a > b. Both a and b must be real, but one or both can be constants (see equal() above). The dimensionality of the result matches the dimensionality of the largest parameter. IFFT(inWave,options) Returns the IFFT of inWave subject to the options field. The options field corresponds to the /C and /Z flags of the IFFT operation. Set the first bit to 1 if you want to allow real-valued output (in the case of a complex input of 2n+1 rows. Set the second bit to 1 if you want to disable the zero centering. Other bits are reserved. Note that MatrixOP does not support wave scaling and therefore it does not produce the same wave scaling changes as the IFFT operation. Identity(n,m) Identity(n) Creates a computational object that is an identity matrix. If you use a single argument n, the identity created is an n xn square matrix with 1's for diagonal elements (the remaining elements are set to zero). If you use both arguments, the function creates an n xm zero matrix and fills its diagonal elements with 1's. Note that the identity is created at runtime and persists only for the purpose of the specific operation. imag(inWave) Returns the imaginary part of inWave. Inv(matrixA) Returns the inverse of a square matrixA. log(z) Returns the log (i.e., log base 10) of a generic argument z which can be real or complex, scalar or a matrix. ln(z) Returns the natural logarithm of a generic argument z which can be real or complex, scalar or a matrix. mag(inWave) Returns a real valued wave containing the magnitude of each element of inWave. This is equivalent to the Abs() function. magSqr(inWave) Returns a real value wave containing the square of a real inWave or the squared magnitude of complex inWave. Normalize(inWave) Returns a normalized version of a vector or a matrix. Normalization is such that the returned wave should have a unity magnitude except if all entries are zero, in which case output is unchanged. NormalizeCols(w) Divides each column of the real wave w with the square root of the sum of the squares of all elements of the column. NormalizeRows(w) Divides each row of the real wave w with the square root of the sum of the squares of all the elements in that row. numType(z) Returns the number type for the element passed to this function. p2Rect(inWave) Performs the equivalent of the p2rect function on each element of inWave, i.e., each complex number of inWave is converted from polar to rectangular representation. phase(inWave) Returns a real valued wave containing the phase of each element of inWave calculated using phase=atan2(y,x). Pi Returns powC(z1,z2) Returns the complex valued z1^z2 where z1 and z2 can be real or complex. powR(x,y) Returns x^y for real x and y. r2Polar(inWave) Performs the equivalent of the r2polar function on each element of inWave, i.e., each complex number (x+iy) is converted into the polar represenation r,theta with x+iy=r*exp(i*theta) real(inWave) Returns the real part of inWave. rec(inWave) Returns the reciprocal of each element in inWave. round(z) Rounds z to the nearest integer. The rounding method is "away from zero". row(w,r) Returns row r from matrix wave w. sin(z) Returns the sine of the generic argument z. sqrt(z) Returns the square root of the generic argument z. subtractMean(w,opt) Computes the mean of the real wave w and returns the values of the wave minus the mean value (opt=0). Computes the mean of each column and subtracts it from that column (opt=1). Subtracts the mean of each row from row values (opt=2). sum(z) Returns the sum of all the elements in expression z. sumSqr(inWave) Returns the sum of the squares of all elements in inWave. SyncCorrelation(w) Returns the synchronous spectrum correlation matrix for a real valued input matrix wave w. See also asyncCorrelation. tan(z) returns the tangent of the generic argument z. Trace(matrixA) Returns a real or complex scalar which is the sum of the diagonal elements of matrixA. If matrixA is not a square matrix, the sum is over the elements for which the row and column indices are the same. TriDiag(w1,w2,w3 ) Returns a tri-diagonal matrix where w1 is the upper diagonal, w2 the main diagonal and w3 the lower diagonal. If w2 has n points than w1 and w3 are expected to have n-1 points. The waves can be of any numeric type and the returned wave has a numeric type that accommodates the input. waveMap(w1, w2 ) Returns an array of the same dimensions as w2 containing the values w1[w2[i][j]]. The data type of the output is the same as that of w1. Values of w2 are taken as 1D integer indices into the w1 array. See also IndexSort.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote