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!