필터 지우기
필터 지우기

Getting around &/| operator errors in optimization toolbox

조회 수: 2 (최근 30일)
Morgan Blankenship
Morgan Blankenship 2021년 7월 26일
I've got a variable (ER) defined as follows:
ER = XO <= -(Lx-wx)/2 & YO <= -(Ly-wy)/2; % Bottom-left feature of unit cell
ER = ER | XO >= +(Lx-wx)/2 & YO <= -(Ly-wy)/2; % Bottom-right feature of unit cell
ER = ER | XO <= -(Lx-wx)/2 & YO >= +(Ly-wy)/2; % Top-left feature of unit cell
ER = ER | XO >= +(Lx-wx)/2 & YO >= +(Ly-wy)/2; % Top-right feature of unit cell
Here XO and YO are x/y axis meshgrids that range from -Lx/2 to Lx/2 and -Ly/2 to Ly/2 . Lx/Ly are spacings between features and wx/wy are widths of the features. Essentially ER here is getting filled with 1s if its position corresponds to a feature and 0s if not in a meshgrid. For example, with random values for Lx/Ly and wx/wy an image of it shows this:
My issue is that once I change Lx/Ly and wx/wy to optimvars they toolbox doesn't like the &/| operators and throws this error:
Operator '&' is not supported for operands of type 'optim.problemdef.OptimizationInequality'.
Is anyone aware of a way to get the same effect of the code shown without using &/|? I'm sure its something super simple I'm overlooking but I've been staring at a blinking cursor for way too long trying to figure it out. If its something that is fixed in later releases I have no issue updating it.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by