Why am I not able to generate new struct in my for loop?

조회 수: 1 (최근 30일)
Robert  Flores
Robert Flores 2019년 10월 2일
답변: Walter Roberson 2019년 10월 2일
Hello,
I am trying to make a new struct in my varible SBOB, such that it contains relative velocities. I have some structs already contained in the varible assignment SBOB, such as the velocities I want to take the differences of. I do not know why the script is not working, I used this same for loop to gerenate those velocities I am trying to take the diffeerences from. Below is a copy of my code so far, if anyone can help me resolve this issue, it will be greatly appreciated.
Sincerely,
Robert
CODE:
for p = 1:length(SBOB)
for r = 1:3 % This is not for all channels, just bridge & tower parts
for h = [8 9 10]
for w = [11 12 13]
for c = [14 15 16]
SBOB{p}.rel_disp_LW(:,r) = SBOB{p}.disp(:,w) - SBOB.disp(:,h)
SBOB{p}.rel_disp_SW(:,r) = SBOB{p}.disp(:,c) - SBOB.disp(:,h)
end
end
end
end
end

채택된 답변

Walter Roberson
Walter Roberson 2019년 10월 2일
for p = 1:length(SBOB)
for r = 1:3 % This is not for all channels, just bridge & tower parts
for h = [8 9 10]
for w = [11 12 13]
SBOB(p).rel_disp_LW(:,r) = SBOB(p).disp(:,w) - SBOB(p).disp(:,h);
for c = [14 15 16]
SBOB(p).rel_disp_SW(:,r) = SBOB(p).disp(:,c) - SBOB(p).disp(:,h);
end
end
end
end
end

추가 답변 (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