classdef app1 < matlab.apps.AppBase
properties (Access = public)
MaximumDistancebetween2cellsEditField matlab.ui.control.NumericEditField
properties (Access = public)
methods (Access = private, Static)
function [c,ceq] = nlincon(p,coord)
c(n) = 32^2-((p(i,1)-coords(j,1))^2 + (p(i,2)-coords(j,2))^2);
function out = coordsAction(coords)
function value = optimization(xval,yval,xmin,ymin,coords,cdf,xq,yq)
initialVal{1,1}(1,1) = xval + xmin;
initialVal{1,1}(1,2) = xval - ymin;
initialVal{1,1}(2,1) = xval + xmin;
initialVal{1,1}(2,2) = xval + ymin;
p1 = @(Point) interp2(xq,yq,cdf,Point(1,1),Point(1,2),'nearest');
p2 = @(Point) interp2(xq,yq,cdf,Point(2,1),Point(2,2),'nearest');
newCoords = app1.coordsAction(coords)
nonlcon = @(p) app1.nlincon(p,newCoords);
lb1(1,1) = initialVal{1,1}(1,1) ;
lb1(1,2) = initialVal{1,1}(1,2) - ymin*2;
ub1(1,1) = initialVal{1,1}(1,1) ;
ub1(1,2) = initialVal{1,1}(1,2) ;
lb1(2,1) = initialVal{1,1}(2,1) ;
lb1(2,2) = initialVal{1,1}(2,2) ;
ub1(2,1) = initialVal{1,1}(2,1) ;
ub1(2,2) = initialVal{1,1}(2,2) + ymin*2;
W1 = @(X) -1+(1-p1(X))*(1-p2(X));
options = optimoptions('fmincon','Algorithm','sqp');
[value,~,exitflag] = fmincon(W1,initialVal{1,1},[],[],[],[], lb1, ub1, nonlcon, options);
methods (Access = private)
xmin = app.postprocess.xmin;
ymin = app.postprocess.ymin;
coords = app.postprocess.coords;
cdf = app.postprocess.cdf;
completeCellPositions={};
[i, j] = ind2sub([nX, nY], idx);
temp1 = app1.optimization(xVal,yVal,xmin,ymin,coords,cdf,xq,yq);
completeCellPositions = [completeCellPositions, temp1];
app.postprocess.cellPos = completeCellPositions
methods (Access = private)
function PostprocessButtonPushed(app, event)
cellPos = app.postprocess.cellPos;