Getting around &/| operator errors in optimization toolbox
조회 수: 2 (최근 30일)
이전 댓글 표시
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/695804/image.png)
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!