From: alfann on 9 Jun 2010 02:54 Dear collegues, If I have this matrix: U1=[0 1 0 0 3; 0 0 0 0 0; 0 0 1 0 0; 0 3 0 0 0; 0 0 0 5 0; 0 0 0 0 3] and we see 1 and 3 are in the first row but 3 is only in the last row. I want to check: if the same number in the first row of the matrix (except zero 0) is found in the last row of the matrix (except zero 0), the value of this variable (Result_matrix=1). How can I do that please?
From: Jos (10584) on 9 Jun 2010 07:15 alfann <alfann.net(a)hotmail.com> wrote in message <1476671741.303915.1276080883937.JavaMail.root(a)gallium.mathforum.org>... > Dear collegues, > If I have this matrix: > U1=[0 1 0 0 3; 0 0 0 0 0; 0 0 1 0 0; 0 3 0 0 0; 0 0 0 5 0; 0 0 0 0 3] > and we see 1 and 3 are in the first row but 3 is only in the last row. > I want to check: > if the same number in the first row of the matrix (except zero 0) is found in the last row of the matrix (except zero 0), the value of this variable (Result_matrix=1). > How can I do that please? Combine ANY, ISMEMBER and NONZEROS, as in any(ismember(nonzeros(U1(1,:)),nonzeros(U1(end,:)))) Jos
From: Jos (10584) on 9 Jun 2010 07:19 alfann <alfann.net(a)hotmail.com> wrote in message <1476671741.303915.1276080883937.JavaMail.root(a)gallium.mathforum.org>... > Dear collegues, > If I have this matrix: > U1=[0 1 0 0 3; 0 0 0 0 0; 0 0 1 0 0; 0 3 0 0 0; 0 0 0 5 0; 0 0 0 0 3] > and we see 1 and 3 are in the first row but 3 is only in the last row. > I want to check: > if the same number in the first row of the matrix (except zero 0) is found in the last row of the matrix (except zero 0), the value of this variable (Result_matrix=1). > How can I do that please? and if they non-zero values need to be in the same spots as well any(U1(1,:) == U1(end,:) & (U1(1,:) * U1(end,:))) Jos
|
Pages: 1 Prev: Compiling executable with Mingw Next: matlab script to processor instructions |