MATLAB: Hi this function should actually visualize a model but unfortunately its not working could someone kindly please fix it

sliceomatic

function PitNums = Visualise_Pit(XC,YC,ZC,Pit)
Visualise_pit brings up GUI showing slices of contours which allow visualisation of nested shell positions.
% Inputs
%---------------------
%Pit is an nxs array of binary decision variables equal to 1 if block n is
%in the optimal pit for shell s and 0 otherwise.
%XC,YC and ZC are nx1 arrays containing the x,y and z position (depth) of
%the centroid of each block.
%----------------------

% Outputs
%----------------------
%PitNums is the interpolation of the incremental pit shells that each block
%belongs to onto an xyz grid for volume viewing. Where blocks belong to
%more than one pit the lower pit number (lower RF pit) is chosen so that
%nesting can be visualised.
Pit(Pit<1) = 0;
Pit = Pit(1:size(XC),:);
PitUnique = Pit;
for i = 2:size(Pit,2)
PitUnique(:,i) = Pit(:,i) - Pit(:,i-1);
PitNumsScat = sum(PitUnique.* (repmat((1:size(Pit,2)),size(Pit,1),1)),2);
end
XC = XC + 9999;
YC = YC + 9999;
ZC = ZC + 9999;
Z = nonzeros(ZC.*(sum(PitUnique,2)));
X = nonzeros((sum(PitUnique,2)).*XC);
Y = nonzeros((sum(PitUnique,2)).*YC);
j = 1;
XC = XC - 9999;
YC = YC - 9999;
ZC = ZC - 9999;
X = X - 9999;
Y = Y - 9999;
Z = Z - 9999;
if isempty (nonzeros((sum(PitUnique,2))))
['Pit Shell number ' (num2str(PitNum)) ' is uneconomic']
end
PitNums = TriScatteredInterp(XC,YC,ZC,PitNumsScat,'natural');
xgv = unique(XC);
ygv = unique(YC);
zgv = unique(ZC);
[X,Y,Z] = meshgrid(xgv,ygv,zgv);
pgv = PitNums(X,Y,Z);
sliceomatic(pgv,xgv,ygv,zgv);

Best Answer

Pit(1:size(XC),:) is an invalid use of the colon operator. Either give the dimension number to size() or else switch to length() -- but remember that length is 0 if any dimension is empty and otherwise is the largest dimension, not the first dimension.
Beyond that, you need to tell us what we should be looking for. Why do you think there is an error? Remember we do not have your data and we do not know what the graph "should" look like.
Related Question