Element Array cell checking

조회 수: 3 (최근 30일)
Ikenna Okoye
Ikenna Okoye 2020년 4월 20일
댓글: Sriram Tadavarty 2020년 4월 20일
Hi, im trying to create an alogorythm that prevent overlapping block generation in simulink. The intent is for the code to go through each array and compare the 4 points in each generated block for elements and 3points for nodes and check wether the newly generated block overlaps with the previous block. My code below shows my attempt at this:
for iElements = 1:numel(elementArray)
if elementArray(1).yArray{i} == elementArray(2).yArray{i} && elementArray(1).xArray{i} < elementArray(2).xArray{i)
centroidElements = centroidElements{elementArray,:} + abs(elementArray.xArray(1)-elementArray.xArray(2)) + defaultPadding; % if this condition is true, add padding to the centroid
else
end
elementArray = 1X2 struct
NodeArray = 1X3 struct
centroidELement = 1X2 cell
Im geting the following error when run:
Brace indexing is not supported for variables of this type.
Error in boeing.fuels.tubing.blockPlacement (line 8)
if elementArray(1).yArray{1i} == elementArray(2).yArray{1i}...
Can anyone help me along to get this running?
  댓글 수: 3
Ikenna Okoye
Ikenna Okoye 2020년 4월 20일
편집: Ikenna Okoye 2020년 4월 20일
This yArray is a reference within the struct of elementArray, so it will be a row vector along with xArray.
Sriram Tadavarty
Sriram Tadavarty 2020년 4월 20일
If its a row vector, then the indexing should be through () rather than {}. Use elementArray(1).yArray(iElements)

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

답변 (0개)

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by