How to find differences of 2 matrices which contain other matrices as elements?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
o1 = eye(3,3);
o6=[1 -1 0; 1 0 0; 0 0 1];
o3=[0 -1 0;1 -1 0 ;0 0 1];
o2=[-1 0 0 ;0 -1 0; 0 0 1];
o3m=[-1 1 0; -1 0 0 ; 0 0 1];
o6m=[0 1 0; -1 1 0 ; 0 0 1];
omxx=[0 -1 0;-1 0 0; 0 0 1];
omx=[-1 1 0; 0 1 0; 0 0 1];
omy=[1 0 0 ;1 -1 0 ;0 0 1];
omxmx=[0 1 0;1 0 0; 0 0 1];
omx2x=[1 -1 0; 0 -1 0; 0 0 1];
om2xx=[-1 0 0 ; -1 1 0; 0 0 1];
G={o1,o6,o3,o2,o3m,o6m,omxx,omx,omy,omxmx,omx2x,om2xx};
labelsG={"o1","o6","o3","o2","o3m","o6m","omxx","omx","omy","omxmx","omx2x","om2xx"};
H={o1,o2};
labelsH={"o1","o2"};
K=setdiff(G,H);
Here my code. I want to find differences of G and H as J=[o6,o3,o3m,o6m,omxx,omx,omy,omxmx,omx2x,om2xx]
But it's not working
0 comentarios
Respuestas (2)
Jan
el 15 de Dic. de 2020
The main problem is the choice of the data representation. Using an indexed field would allow to call setdiff().
Data.o1 = eye(3,3);
Data.o6 = [1 -1 0; 1 0 0; 0 0 1];
Data.o3 = [0 -1 0;1 -1 0 ;0 0 1];
Data.o2 = [-1 0 0 ;0 -1 0; 0 0 1];
Data.o3m = [-1 1 0; -1 0 0 ; 0 0 1];
Data.o6m = [0 1 0; -1 1 0 ; 0 0 1];
Data.omxx = [0 -1 0;-1 0 0; 0 0 1];
Data.omx = [-1 1 0; 0 1 0; 0 0 1];
Data.omy = [1 0 0 ;1 -1 0 ;0 0 1];
Data.omxmx = [0 1 0;1 0 0; 0 0 1];
Data.omx2x = [1 -1 0; 0 -1 0; 0 0 1];
Data.om2xx = [-1 0 0 ; -1 1 0; 0 0 1];
G = {"o1","o6","o3","o2","o3m","o6m","omxx","omx","omy","omxmx","omx2x","om2xx"};
H = {"o1","o2"};
Now setdiff(G, H) get the difference directly. Afterwards you can use something like Data.(G{1}) to get the corresponding values.
0 comentarios
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!