필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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
Mitchell Thurston
Mitchell Thurston 2021년 12월 11일
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.
juan sanchez
juan sanchez 2021년 12월 11일
I have information stored in a suite where each location is able to store velocity in (rows indicating time, columns indicating heights). The only active locations are 1 2 4 and 6. However I want to extract that information from the suite so that I have it as a normal matlab matrix Velocity(rows,columns, pages) so that each page takes the location.
The length of location will give me the right order 1 2 3 4 as I wish the pages to be stored but the suite has the information in locations 1 2 4 and 6. I tried to do a double loop but the information is all being overwritten. Then the size of the first 2 locations has 15600 rows but the last two rows have a size of 20800 so preallocating is also an issue.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by