How to run this loop and make sure the information from a struct is assigned as a simple m x n x k ? My loop is overwriting the information
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to have the N vector as an m x n x k extracting the information from a struct suite
but the loop here is being overwritten. How can I avoid the overwriting in this loop?
if isempty(locations) || nargin==2
locations = find([Suite(:).active]); %active locations [1 2 4 6]
end
for loc = 1:13
if Suite(loc).active
for i=locations
M=zeros(size(Suite(i).scani,1), size(Suite(i).scani,2), length(find([Suite(i).active])));
k=1:length(locations)
M(:,:,k)=Suite(i).scani;
N(:,:,k)=M
end
DDD1=N(:,:,1);
DDD2=N(:,:,2);
DDD3=N(:,:,3);
DDD4=N(:,:,4);
end
end
2 comentarios
Mitchell Thurston
el 11 de Dic. de 2021
It's kind of unclear what you're trying to do here, but I'm guessing you want to be doing "N(:,:,i)=" instead of "N(:,:,k)=" since k should be the same no matter which iteration you're on. There's a few other problems I think I see, but I'm not really sure what the code is trying to accomplish so I can't say for sure.
Respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays 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!