how to make the same length in the struct
Mostrar comentarios más antiguos
i've a struct with filed of various length (see pics)
i want to make the same length of this array
and assign the zero in the data that is not there at the end
i try this ..but it's not correct
>> [Sis.d]
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
8 comentarios
Matt J
el 28 de Ag. de 2023
We cannot see the form of Sis from the .png file. It would be best to attach Sis itself in a .mat file.
shamal
el 28 de Ag. de 2023
Matt J
el 28 de Ag. de 2023
The repost has the same issue. The Sis variable is not attached.
shamal
el 29 de Ag. de 2023
@Luca Re: I moved your comment here and deleted my answer, because it is clear that you have not sufficiently explained what you are trying to achieve. At no point in your question do you mention anything like "sync" or synchronizing the data with dates or anything like that. Sorry, but my mind-reading crystal ball is currently being fixed as it broke last week. If you want further help, please explain what you want to achieve AND provide the expected output in a MATLAB syntax using the provided data.
Bruno Luong
el 29 de Ag. de 2023
Editada: Bruno Luong
el 29 de Ag. de 2023
This thread becomes completely a mess. The problem asked now has nothing to do with Padding arrays in structure.
The other thread should not be closed.
Respuesta aceptada
Más respuestas (1)
s=struct('a',rand(5,1),'b',rand(3,1),'c',rand(6,1))
maxheight = max(structfun(@height,s));
padarrays = structfun(@(x) [x; zeros(maxheight-height(x),1)], s, 'unif', 0)
padarrays.a
padarrays.b
padarrays.c
1 comentario
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!