Clear Filters
Clear Filters

Getting around &/| operator errors in optimization toolbox

1 view (last 30 days)
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.

Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!