Comparing the two structure
Mostrar comentarios más antiguos
I need to compare the two structure and remove the matching fieldname. Is it possible?
How can i do it?
Thanks a lot
2 comentarios
B.k Sumedha
el 18 de Jun. de 2015
Yes.It can be done.
Gopalakrishnan venkatesan
el 18 de Jun. de 2015
Respuesta aceptada
Más respuestas (1)
B.k Sumedha
el 18 de Jun. de 2015
Editada: B.k Sumedha
el 18 de Jun. de 2015
U can use the isequal command to compare between structs.
tf = isequaln(A,B)
And if the result is 1,u can remove those fieldname like for example:
function B = column_removal(A,n)
A = [1 2 3; 4 5 6];
n=2;
A(:,n)=[];
B = A;
end
In this example u will be removing the 2nd coulmn.
3 comentarios
Guillaume
el 18 de Jun. de 2015
If the question is indeed about structures, then this answer is way off the mark! See Azzi's answer for the correct solution.
B.k Sumedha
el 18 de Jun. de 2015
Cant isequlan function compare two structures??
Yes, it can, and it will tell you whether the two structures have the exact same field names and field values.
It won't give you the list of fields that have the same name.
Your example of column removal has nothing to do with structures.
Note: I'm not belittling your answer as the OP is obviously happy with it since he accepted it. But if somebody searches the forum for a way to remove matching field names, I'd rather they went to the correct answer to that problem.
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!