f



check if a matrix is diagonal

hi, everyone!

i'm doing a little program, and it would be usefull to know if the matrix the user inputs id diagonal.

i know how to do a function that does so, but using a for(...;...;...) and i've seen
recently that people defines functions like this: 

issym=@(x) all(all(x==x.'));
    tf=issym(mat);

(this one checks if the matrix is symetric)

so i would aprciate, a function that check if a matrix is diagonal, or at least some explanation for me to build it that way.

thanks in advance
0
santi
12/21/2010 4:07:24 PM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader. Post Follow

14 Replies
709 Views

Similar Articles

[PageSpeed] 50

Perhaps this,

isdiag=@(A) ~nnz(A-spdiags(diag(A),0,size(A,1)));
0
Matt
12/21/2010 4:47:05 PM
"Matt J" wrote in message <ieqlm9$90l$1@fred.mathworks.com>...
> Perhaps this,
> 
> isdiag=@(A) ~nnz(A-spdiags(diag(A),0,size(A,1)));

Hey, thanks for the answer, but i tried it and didn't work

the function:

function [ res ] = is_diagonal( mat )
    isdiag=@(A) ~nnz(A-spdiags(diag(A),0,size(A,1)));
    res=isdiag(mat);
end

in the terminal: 

m2 =
     1     0     0
     0     2     0
     0     0     3

>> is_diagonal(m2)
ans =
     0
0
santi
12/21/2010 5:58:08 PM
Make that

sdiag=@(A) ~nnz(A-spdiags(diag(A),0,speye(size(A,1))));
0
Matt
12/21/2010 6:14:07 PM
"santi" wrote in message <ieqjbs$7g4$1@fred.mathworks.com>...
> hi, everyone!
> 
> i'm doing a little program, and it would be usefull to know if the matrix the user inputs id diagonal.
> 
> i know how to do a function that does so, but using a for(...;...;...) and i've seen
> recently that people defines functions like this: 
> 
> issym=@(x) all(all(x==x.'));
>     tf=issym(mat);
> 
> (this one checks if the matrix is symetric)
> 
> so i would aprciate, a function that check if a matrix is diagonal, or at least some explanation for me to build it that way.
> 
> thanks in advance

A few things could clean this up. I might check
to verify that the matrix is only 2-d. And my help
would be complete, with a descriptive H1 line.

John

function result = isdiagonal (A)
% help block (yada, yada, yada)
[I,J] = find(A);
if ~isempty(I)
  result = all(I == J);
else
  % make the simple choice that an all zero matrix
  % or an empty array is by definition diagonal, since
  % it has no non-zero off diagonals.
  result = true;
end
0
John
12/21/2010 6:15:23 PM
"santi" wrote in message <ieqjbs$7g4$1@fred.mathworks.com>...
> hi, everyone!
> 
> i'm doing a little program, and it would be usefull to know if the matrix the user inputs id diagonal.
> 
> i know how to do a function that does so, but using a for(...;...;...) and i've seen
> recently that people defines functions like this: 
> 
> issym=@(x) all(all(x==x.'));
>     tf=issym(mat);
> 
> (this one checks if the matrix is symetric)
> 
> so i would aprciate, a function that check if a matrix is diagonal, or at least some explanation for me to build it that way.
> 
> thanks in advance

I would suggest:

isdiagonal = isequal(diag(diag(X)),X)

The solutions with, for instance, find fail for cases with zeros on the diagonal ... In my opinion zeros(N) is also a valid diagonal matrix.

Jos
0
Jos
12/21/2010 8:18:21 PM
John's solution is the best, because it works for large matrix, straight forward, easy to understand and fast.

Bruno
0
Bruno
12/21/2010 8:30:24 PM
I would probably recommend the following modification to John's code. The reason is that for large dense matrices, the results of find() could consume three times as much data as the original matrix. 
Pre-checking  nnz(A)>size(A,1) can prevent a lot of  unnecessary memory alloc.

@Jos: checking whether the find() returns empty takes care of the zero(N) case. 
diag(diag(...)) seems sub-optimal from a memory alloc point of view.


function result = isdiagonal (A)
% help block (yada, yada, yada)

if nnz(A)>size(A,1) %<----Matt J added this pre-check
 result=false;
return

[I,J] = find(A);

if ~isempty(I)
  result = all(I == J);
else
  % make the simple choice that an all zero matrix
  % or an empty array is by definition diagonal, since
  % it has no non-zero off diagonals.
  result = true;
end 
 
0
Matt
12/21/2010 8:41:21 PM
"Jos (10584)" wrote in message <ier22d$p4c$1@fred.mathworks.com>...
> 
> I would suggest:
> 
> isdiagonal = isequal(diag(diag(X)),X)
> 
> The solutions with, for instance, find fail for cases with zeros on the diagonal ... In my opinion zeros(N) is also a valid diagonal matrix.
> 
> Jos

I believe John's code did take into account a zeros matrix in the ELSE clause.
0
Matt
12/21/2010 8:47:20 PM
Why not go ahead and make it compatible with MATLAB's DIAG function too?



function [yn,k] = isdiag(A)
% First return arg indicates if the input is diagonal, second indicates 
% which diagonal.  To check for "proper diagonality" (nonzeros on the
% main diagonal only) we want k = 0.

yn = find(A);

if isempty(yn)
    % If zeros is a diagonal matrix.
    yn = true;
    k = 0;
    return
end

k = yn(1);
yn = all(diff(yn)==size(A,1)+1);

if k>size(A,1)
    k = floor(k/size(A,1));
else
    k = -(k-1);
end
0
Matt
12/21/2010 9:05:24 PM
Another proposal:

 isdiag=@(A) nnz(A)==nnz(diag(A))

or if you want to check a particular diagonal

 isdiag=@(A,k) nnz(A)==nnz(diag(A,k))
0
Matt
12/21/2010 9:34:07 PM
"Matt J" wrote in message <ier3dh$ljg$1@fred.mathworks.com>...
> I would probably recommend the following modification to John's code. The reason is that for large dense matrices, the results of find() could consume three times as much data as the original matrix. 
> Pre-checking  nnz(A)>size(A,1) can prevent a lot of  unnecessary memory alloc.
> 

Yes, after I posted, I realized I wanted to add that feature
too. Good addition.

John
0
John
12/21/2010 9:57:05 PM
Here is a MEX file for checking a full matrix is diagonal:

/*************************************************************************
 * Mexfile isdiagmex.c
 * [res] = isdiagmex(A)
 *
 * return 1 if A is a diagonal matrix
 * Note: sparse matrix not supported
 *
 *  mex isdiagmex.c % on 32-bit
 *  mex -largeArrayDims isdiagmex.c % on 32-bit
 *************************************************************************/
#include "mex.h"

/* Define correct type depending on platform 
  You might have to modify here depending on your compiler */
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 int64;
typedef __int32 int32;
typedef __int16 int16;
typedef __int8 int08;
#else /* LINUX + LCC, CAUTION: not tested by the author */
typedef long long int int64;
typedef long int int32;
typedef short int16;
typedef char int08;
#endif

#define A prhs[0]
#define R plhs[0]
        
#define DIAG_ENGINE(pr, pi, pAType) \
        pr = (pAType*)PrA; \
        pi = (pAType*)PiA; \
        if (PiA==NULL) \
           for (i=0; i<n; ++i) { \
                if ((pr[i]!=0) && (i % m)) { \
                    res = 0; \
                    break; \
                } } \
        else { \
            for (i=0; i<n; ++i) \
                if ((pr[i]!=0 || pi[i]!=0) && (i % m)) { \
                    res = 0; \
                    break; \
                } }      

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {

    mxClassID ClassID;
    mwSize i, m, n;
    double *PrA, *PiA;
    double *prdouble, *pidouble;
    float *prsingle, *pisingle;
    int64 *pr64, *pi64;
    int32 *pr32, *pi32;
    int16 *pr16, *pi16;
    int08 *pr08, *pi08;
    
    double res = 1;
    
    if( nrhs != 1 )
        mexErrMsgTxt("One arguments required.");
    
    if (mxIsSparse(A))
        mexErrMsgTxt("Sparse not suppored.");
    
    m = mxGetM(A);
    n = mxGetN(A);    
    n *= m;
    
    /* Get data pointers */
    PrA = mxGetPr(A);
    PiA = mxGetPi(A);
    m++;
    
    /* Get class of input matrix */
    ClassID = mxGetClassID(A);
    
    switch (ClassID) {
        case mxDOUBLE_CLASS:
            DIAG_ENGINE(prdouble, pidouble, double);
             break;
        case mxSINGLE_CLASS:
            DIAG_ENGINE(prsingle, pisingle, float);
             break;
        case mxINT64_CLASS:
        case mxUINT64_CLASS:
            DIAG_ENGINE(pr64, pi64, int64);
             break;
        case mxINT32_CLASS:
        case mxUINT32_CLASS:
            DIAG_ENGINE(pr32, pi32, int32);
             break;
        case mxCHAR_CLASS:
        case mxINT16_CLASS:
        case mxUINT16_CLASS:
            DIAG_ENGINE(pr16, pi16, int16);
             break;
        case mxLOGICAL_CLASS:
        case mxINT8_CLASS:
        case mxUINT8_CLASS:
            DIAG_ENGINE(pr08, pi08, int08);
    }
            
    R = mxCreateDoubleScalar(res);
    
    return;
    
}

// Bruno
0
Bruno
12/21/2010 9:58:07 PM
"Matt J" wrote in message <ier6gf$bld$1@fred.mathworks.com>...
> Another proposal:
> 
>  isdiag=@(A) nnz(A)==nnz(diag(A))

This is very good, but it needs extra lines to take care of the case such as A = [1:10] for example.

Bruno
0
Bruno
12/22/2010 8:09:05 AM
Dear Bruno,

I think, the MEX approach is the cleanest one, because it uses a minimum of temporary memory.

Some minor comments:
> #if defined(_MSC_VER) || defined(__BORLANDC__)
> typedef __int64 int64;
> typedef __int32 int32;
> ...
> #else /* LINUX + LCC, CAUTION: not tested by the author */
> typedef long long int int64;
> typedef long int int32;

You can leave these boring definitions to "tmwtypes.h", which is included in "mex.h": int64_T, uint64_T, int32_T etc. is defined properly already.

I had some strange experiences with NaNs: Although the IEEE standard defines every comparison with NaN as FALSE, some compilers fail.
But is [NaN, 0; 0, NaN] a diagonal matrix? And [NaN, 0; 0, 0]? And [NaN]? And [0, NaN; NaN, 0]??? I have no idea how to treat NaN's "correctly" here.

Unfortunately the MSVC2008 compiler does not offer ISNANF for FLOAT type, such that for SINGLE Matlab arrays the ugly bit checks are necessary to catch NaNs.

>            for (i=0; i<n; ++i) { \
>                 if ((pr[i]!=0) && (i % m))
My first idea was, that checking (i % m) is slower than a loop, which checks if SIZE(X,1) subsequent elements are zeros followed by a single arbitrary element. But (i %m) is evaluated only it (pr[i]!=0), which is very seldom for large arrays.

Finally we'd need some numerical limit, because [1, eps; eps, 1] could be almost diagonal, diagonal or not diagonal depending on the calling algorithm. 

Kind regards, Jan
0
Jan
12/22/2010 9:32:04 AM
Reply:

Similar Artilces:

Creating a J*J Diagonal Matrix with Jth Diagonal element is also a matrix
Hello, I am a new beginner of Matlab and I want to create a Diagnoal Matrix with the main diagnoal as (A1,A2,A3,....,Aj) where Aj is also a matrix which is defined as (a11,a12,a13;a21,a22,a23;a31,a32,a33). How can I define Aj as a variable in the m file then create the diagnoal matrix through Aj? Could someone help on this please? Many Thanks in Advance! "Jie " <jz286@cam.ac.uk> wrote in message <h6selu$9ng$1@fred.mathworks.com>... > Hello, > > I am a new beginner of Matlab and I want to create a Diagnoal Matrix with the main diagnoal as (A1,A2,A3,....,Aj) w...

Re: check if a square matrix is diagonal
On 1/6/11 at 2:06 AM, xiaochu@gmail.com (benyaya) wrote: >What I try to do is extract the diagonal, subtract if from the >matrix, then compare the new matrix with 0. My code doesn't work out >though, can anyone help? thanks a lot. >checkIfDiagonalMatrix[m_] = Module[{d, mtemp}, >d = Dimensions[m]; >mtemp = DiagonalMatrix[Diagonal[m]] - m; >If[mtemp == Table[Table[0, {i, 1, d}], {i, 1, d}], >True, >False] >] One immediate problem is Dimensions[m] returns a list. Consequently, d cannot be used as the end point for the Table iterator. The following will do what you want and has the same logic as you have used checkIfDiagonalMatrix[m_] := Module[{d, mtemp}, d = Dimensions[m]; mtemp = DiagonalMatrix[Diagonal[m]] - m; If[mtemp == ConstantArray[0,d], True, False] ] Note, I used SetDelayed (:=) not Set (=) But I think this logic is doing more work than necessary. I would accomplish this as: diagonalQ[ m_] := (ArrayRules[SparseArray@m] /. HoldPattern[{a_, a_} -> _] :> Sequence[]) == {} If m is a diagonal matrix this should be pretty fast. However, it m is a dense array, this might be fairly slow. What I am doing is using ArrayRules to extract all of the non-zero elements of m. Those are returned as rules that look like {m,n}->number. I then apply a pattern matching rule that deletes all cases where m and n are equal and compare that to the empty list {}. ...

Re: check if a square matrix is diagonal #2
On 7 Jan 2011, at 10:12, Bill Rowe wrote: > On 1/6/11 at 2:06 AM, xiaochu@gmail.com (benyaya) wrote: > >> What I try to do is extract the diagonal, subtract if from the >> matrix, then compare the new matrix with 0. My code doesn't work out >> though, can anyone help? thanks a lot. > >> checkIfDiagonalMatrix[m_] = Module[{d, mtemp}, >> d = Dimensions[m]; >> mtemp = DiagonalMatrix[Diagonal[m]] - m; >> If[mtemp == Table[Table[0, {i, 1, d}], {i, 1, d}], >> True, >> False] >> ] > > One immediate probl...

Re: check if a square matrix is diagonal #5
The sparse-array example ran so fast (on my machine) that it doesn't matter which method you use: m = SparseArray[Band[{1, 1}] -> RandomReal[1, {10000}]]; Timing[UpperTriangularize[m] == LowerTriangularize[m]] {0.000874, True} Timing[Total[Unitize@m, 2] == Total[Unitize@Diagonal[m]]] {0.000417, True} Timing[m == DiagonalMatrix[Diagonal@m]] {0.000559, True} But that's not a general diagonal matrix, which might be something like: m = Developer`ToPackedArray@ Normal@SparseArray[Band[{1, 1}] -> RandomReal[1, {10000}]]; (THAT step was very slow!) ...

Empty matrix and Diagonal matrix
Hi everyone I want to creat a large diagonal matrix.The main diagonal elements of the diagonal matrix is a 3x3 matrix. For example I have a matrix A(3x3),now I should obtain the diagnoal matrix B(300x300),can anybody tell me how to do it? Deeply appreciate your help! Thank you in advance! Nandy Erik wrote: > > > Hi everyone > I want to creat a large diagonal matrix.The main diagonal > elements > of the diagonal matrix is a 3x3 matrix. > For example I have a matrix A(3x3),now I should obtain the diagnoal > matrix B(300x300), >Others I want to know how to create an...

Fast Matrix*Diagonal*Matrix operation
Hi there, I have a code that computes Q'*D(t)*Q many times. Here Q is a fixed mxn matrix with m < n, while the diagonal matrix D depends on the iteration t. Because I have so many iterations that the operation slows done the entire process. I am wondering if there is any way to obtain Q'*D(t)*Q as fast as possible. Maybe from the result of Q'*Q or some kind of decomposition of Q'*Q? Thanks in advance! best, Gongguo "Gongguo Tang" wrote in message <ii7d79$lto$1@fred.mathworks.com>... > Hi there, > > I have a code that compute...

How do I create a diagonal matrix with block matricies on the diagonal?
Hello all, I need to create a square matrix that has square block matricies along the diagonal and zeros everywhere else. That is to say, I need to create a block diagonal matrix where each submatrix is different. The overall matrix needs to have the form: M = - - | sm1 0 0 | | 0 sm2 0 | | 0 0 sm3 | - - Any advice would be greatly appreciated. Either post a reply or email me directly(phatphreak74@yahoo.ca). thanks in advance, the phreak phat phreak wrote: > Hello all, > I need to create a square matrix that has square block matricies > along the diagonal and zeros everywhere el...

Block diagonal matrix from a skew-symmetric matrix
Dear Group members, I'm trying to solve the following algebra problem Consider a skew-symmetric matrix of the form: B=[0,A; -At,0] where 0 stands for a null matrix and At the transpose of matrix A. Is it possible to obtain a transformation of this matrix such as the new matrix in the new coordinates would be a block diagonal matrix of the form: C=[C1,0; 0,C2] with C=Tt * B * T, being T the transformation matrix? If possible how can I obtain such a transformation matrix? Thanks, RV ...

Check for matlab error from Matlab Engine call
Hi, I am using the matlab engine from a C++ program. I call engEvalString() and check for the return value, but the result is zero, even if a Matlab error (like "Undefined function or variable '...') occurs. Is there any way to find out if a Matlab error occured? Thanks, Philipp ...

affecting a matrix rows as diagonal blocks in another matrix
Hi Suppose i have a matrix A= [1 4 5 8 7 3 6 5 2] I want to have a matrix B such each row of it has a row from A at the diagonal B=[1 4 5 0 0 0 0 0 0 0 0 0 8 7 3 0 0 0 0 0 0 0 0 0 6 5 2] how can i do it. I could do it with blkdiag but it supposes i input each row for the matrix, however i need something general since i need it for bigger matrices Thanks "matlab " <keep_smiling2100@yahoo.fr> wrote in message <jtkrgk$js0$1@newscl01ah.mathworks.com>... > Hi > Suppose i have a matrix A= [1 4 5 > 8 7 3 > 6 5 2] > I want to have a matrix B such each row of it has a row from A at the diagonal > > B=[1 4 5 0 0 0 0 0 0 > 0 0 0 8 7 3 0 0 0 > 0 0 0 0 0 0 6 5 2] > > how can i do it. I could do it with blkdiag but it supposes i input each row for the matrix, however i need something general since i need it for bigger matrices % Method 1 c = num2cell(A,2) B = blkdiag(c{:}) % Method 2 [i j] = find(A); B = accumarray([i (i-1)*size(A,2)+j], A(:)) % Method 3 [i j] = find(A); B = sparse(i, (i-1)*size(A,2)+j, A) % Bruno > % Method 1 > c = num2cell(A,2) > B = blkdiag(c{:}) > > % Method 2 > [i j] = find(A); > B = accumarray([i (i-1)*size(A,2)+j], A(:)) > > % Method 3 > [i j...

diagonal of a matrix
Hi, Probably a very silly question, but how can one talk about "two diagonals" of a matrix? I thought the diagonal of a matrix is M(i,i), the one going straight down the middle. Any help greatly appreciated. Bull Dog In addition to other explanations, there is this: <http://mathworld.wolfram.com/Diagonal.html> The diagonal you refer to is the 'main diagonal'. ...

Matlab matrix
How I can put time value like 10:23:34 in a matrix cell. Like below: a(1,2)= 10:23:34 Regards "M" wrote in message <kehbrk$3pp$1@newscl01ah.mathworks.com>... > How I can put time value like 10:23:34 in a matrix cell. Like below: > a(1,2)= 10:23:34 One approach is to use a cell array and have the entry be a string. E.g., a = cell(1,2); a{1,2} = '10:23:34'; James Tursa On 2/1/2013 3:46 PM, James Tursa wrote: > "M" wrote in message <kehbrk$3pp$1@newscl01ah.mathworks.com>... >> How I can put time value like 10:23:34 in a matrix cell. Like below: >> a(1,2)= 10:23:34 > > One approach is to use a cell array and have the entry be a string. E.g., > > a = cell(1,2); > a{1,2} = '10:23:34'; > And another is to use the fractional portion of a datenum representation-- >> a{1,2}=datenum('10:23:34',upper('hh:mm:ss'))- fix(datenum('10:23:34',upper('hh:mm:ss'))) a = [] [0.4330] >> datestr(a{1,2},'HH:MM:SS') ans = 10:23:34 >> -- ...

Matrix, matlab
Hello, a)I need to create an M*M matrix of all zeros, except for one row on ones in the center. M in the matrix will vary from 16, 32,64,128. b)I need to repeat the above for two rows of ones.Here the two rows of ones should be seperated by four rows of zeros. Thank you, athina shah wrote: > Hello, > > a)I need to create an M*M matrix of all zeros, except for one row on > ones in the center. > > M in the matrix will vary from 16, 32,64,128. it will be pretty difficult, since you can not create the rows number 7.5, 15.5 and so one > b)I need to repeat the above ...

diagonal of matrix
Hi all, Is there a non-loop way of obtaining the digonal elements Aii from a matrix A and put them in a vector? A=rand(60); vd=digonal_elements_of(A) %vd is a vector Thanks, Per Look for the 'diag'-function thomas Per S wrote: > > > Hi all, > > Is there a non-loop way of obtaining the digonal elements Aii from > a > matrix A and put them in a vector? > > A=rand(60); > vd=digonal_elements_of(A) %vd is a vector > > Thanks, > Per thomas wrote: > > > Look for > the 'diag'-function > > thomas Ok thanks, I didn't kn...

matrix diagonalization
In the diagonalization operation of a matrix A. [Q Gamma] = eig(A) Q= 1.0000 0 -1.0000 0 0 1.0000 0 -1.0000 0 0 0.0000 0 0 0 0 0.0000 Gamma= -0.0113 0 0 0 0 -0.0253 0 0 0 0 -0.0113 0 0 0 0 -0.0253 "Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.887379e-016." It seems that the eigenvalues are not different and the diagolization is a...

diagonal matrix
Hi, I have a 200x200 matrix and I wish to write certain values (a vector of 1x200) to its diagonal. Can you suggest a way to do it without using loop? Is there any direct command to write to the diagonal of a matrix? Thanks in advance. Regards, Sandeep "Sandeep " <sandeep.gore@yahoo.com> wrote in message <fj82bo$a8b$1@fred.mathworks.com>... > Hi, > > I have a 200x200 matrix and I wish to write certain values > (a vector of 1x200) to its diagonal. Can you suggest a way > to do it without using loop? Is there any direct command > to write to t...

Matrix in a matrix?
Hi to all, I've encountered a problem using Matlab. As I'm not very familiar with matlab, there are functions which I have not used before. What I would like to know, if there is a way to express a matrix within a matrix. For example, R= [ r1 r2 r3 ... rn] where rn=[xn yn tn] and xn, yn, tn are column of numbers. I used the following code below to express the numbers in rn as coloumns for easy referencing. xn=r(:,1); %represents the columns in the matrix yn=r(:,2); tn=r(:,3); My objective is to be able to retrieve information in the matrix easily and compare their values. Meani...

Matrix of matrix
Hi everbody. First of all, I apologize for my English, so please be indulgent with me if my sentences are not grammatically correct. I have some trouble with MATLAB. I have some data in txt files that I catch like that : MFS93A1 = textread('Z:/Fichiers/MFS93.A1.txt','','headerlines',1); MFS93B1 = textread('Z:/Fichiers/MFS93.B1.txt','','headerlines',1); MFM77A1 = textread('Z:/Fichiers/MFM77.A1.txt','','headerlines',1); MFM77C1 = textread('Z:/Fichiers/MFM77.C1.txt','','headerlines',1); Then, in or...

How to put the elements of a matrix to specific locations to a larger matrix in MATLAB?
I have a matrix of larger 4x4, and I have a smaller matrix of 2x2 and their respective row and column positions in the larger matrix. I want to assign the elements of the smaller matrix to the larger matrix on that specific row and column positions with out using any loop, I am doing so, im = zeros(4,4) r=[1 2; 3 4] c=[1 2; 3 4] indices = sub2ind(size(im),r,c); im1=ones(2,2) im(r, c)=im1(:) but it gives exception of, "Subscripted assignment dimension mismatch". any help in this regard will be appreciated. On 8/22/14, 2:20 PM, javed iqbal wrote: >...

load MATRIX data into normal spss file and get rid of the upper diagonal of the matrix
Hi, I have a survey sample file with some 260 variables, that is repeated for 2= 1 different subgroups (this could go up to 50). Per subgroup, I create a co= rrelation matrix over all 260 variables (yes, that can be useful...). I.e.,= I use the CORR command to write out a matrix file. The goal of my intended analysis is to check the pairwise correlations for = outliers. Outliers are defined in comparison to same variable pairs across = all subgroups. Using VARSTOCASES, I can convert the matrix to long format, making all pair= s of the substantive variables the cases in the new ...

check one two check check
check check one twoo Stifler wrote: > check check one twoo You're supposed to say that into a microphone. Here it goes like this: "this is a test, please ignore." -- _______________________________________________________________________ Christopher R. Carlen Principal Laser/Optical Technologist Sandia National Laboratories CA USA crcarle@sandia.gov -- NOTE: Remove "BOGUS" from email address to reply. ...

MATLAB Reshape Challenge: N x d matrix to N/K x d x K matrix
Hi folks, I'm working on parallelizing some machine learning code in MATLAB. I'm using the Parallel Computing Toolbox and the parfor construct; therefore, I have certain restrictions on how I must "slice" into certain data structures accessed within the parfor (parallel for) loop. Basically, I need to reshape my training data from an (N x d) two- dimensional matrix to a fully "slicable" (N/K x d x K) matrix, where K is the number of available parallel threads (which corresponds to the number of "slicable" input data partitions). Here, I would slice among the third dimension, i.e., partitioned_data (:,:,parallel_loop_index_i). (For now, assume N is a multiple of K.) I'm usually very good with reshape, permute, shiftdim, etc., but I am having trouble making this work nicely. I could hack in something like slicable_data_partitions = cat(3, manual_partition_1, manual_partition_2, ..., manual_partition_K) but that's horrible and I was hoping for an efficient one-liner with some combination of reshape, permute, etc. Performance is important, as this will be fairly large scale, i.e., numel(data) on the order of 10^7. Note I can actually get reshape to return output int he desired dimension, however, the d data elements along the second dimension in each of the N rows are no longer in the correct order. Detailed example of desired output: [N x d, 8 x 3]: input_data = reshape(1:24, 3, 8)' % Note transpose input_data = ...

3D Matrix in MATLAB
I am making a project on image processing using MATLAB Can someone please tell me how to enter a 3 d matrix I know to enter a 2d matrix. Like A=[1 2 3; 4 6 6] A= 1 2 3 4 5 6 How is 3d matrix entered shalav: <SNIP wants to create a 3d matrix... one of the many solutions: clear m m(:,:,2)=[1 2 3;4 5 6] m(:,:,1)=pi*m(:,:,2) us try help cat A = rand(4); B = rand(4); C = cat(3,A,B); Anyway MATLAB has a really nice manual, give it a try. us <us@neurol.unizh.ch> wrote: > shalav: > <SNIP wants to create a 3d matrix... > > one of...

combination of matrixes matlab
Hey I’m a new user. I want to perform this: I have 6 matrixes A=[1,2;3;2] B=[…] C=[..] D=[..] E=[..] F=[..] I want to find the possible combinations of those matrixes taken 3 at times and calculate the product of the matrix determiners of each combination In order to find all combinations a can do: MAT={‘A’,’B’,’C’,’D’,’E’,’F’} comb=nchoosek(MAT,3) The results is: comb = 'A' 'B' 'C' 'A' 'B' 'D' 'A' 'B' 'E' 'A' 'B' 'F' 'A' 'C' &#...

Web resources about - check if a matrix is diagonal - comp.soft-sys.matlab

Diagonal - Wikipedia, the free encyclopedia
A diagonal is a line joining two nonconsecutive vertices of a polygon or polyhedron . Informally, any sloping line is called diagonal. The word ...

Number Join + : Join every single number. Horizontal, vertical and diagonal on the App Store on iTunes ...
Get Number Join + : Join every single number. Horizontal, vertical and diagonal on the App Store. See screenshots and ratings, and read customer ...

Police investigate four deliberately lit fires at Rider St, Sandery Ave and Diagonal Rd, Seacombe Gardens ...
POLICE need information to find who deliberately lit four small rubbish or grass fires at Seacombe Gardens early on Tuesday.

WSJ again claims Apple working on larger-screened iPhones up to 6" diagonal [u]
Apple is reportedly testing a variety of next-generation iPhones with larger screen sizes, some up to six inches diagonally, though the devices ...

SteamVR instructions show wireless controllers, 15’ diagonal playspace
New headset has less weight, fewer wires, and Wii-like wrist straps on the controls.

2015 BMW X4 slides in on the diagonal starting at $45,625 in the US
Filed under: New York Auto Show , Crossover , BMW , Luxury If BMW has shown us anything, it's a knack for creating niches and expanding its ...

UAB Blazers Make Tremendous Diagonal Pass to Set Up Big-Time 3-Pointer - Bleacher Report
... aren't giving up yet as they battle it out with the UCLA Bruins in their third-round matchup. Chris Cokley sets up Denzell Watts with the diagonal ...

Witness: Plane did "diagonal cartwheel"
Eyewitness Anthony Castrani describes how Asiana flight 214 performed a "side motion diagonal cartwheel" as it crashed while landing at San Francisco ...

Wind-toppled semitrailer to remain alongside Boulder-bound Diagonal until Tuesday
High winds toppled a semitrailer's load on the Boulder-bound Diagonal Highway near Niwot this afternoon, forcing traffic to divert through the ...

City Rejects Plea to Keep Diagonal Runways to Reduce O'Hare Noise
... are used at night to reduce the noise over some neighborhoods. O'HARE — O'Hare Airport officials Friday rejected pleas to keep two diagonal ...

Resources last updated: 3/28/2016 7:41:21 PM