Commit c1fe17e4 authored by Nicolas Rodriguez's avatar Nicolas Rodriguez

Upload New File

parent a64cca45
%
% Copyright 2019-2020 LIST (Luxembourg Institute of Science and Technology), all right reserved.
%
% Author: Nicolas Rodriguez (nicolas.bjorn.rodriguez@gmail.com)
%
function [feas,errtypes]=checksol(y,cond)
% Checks the state variables stored as columns in y for anomalous values
% error types:
% 0: no error found =)
% 1: forbidden sign found (>0, <0)
% 2: Infinite value found
% 3: NaN found
% 4: Complex value found
errtypes=[];
feas=true;
c=length(cond);
for k=1:c
if strcmp(cond(k),'p')
if any(y(:,k)<0)
feas=false;
if ~any(errtypes==1)
errtypes(end+1)=1;
end
end
elseif strcmp(cond(k),'n')
if any(y(:,k)>0)
feas=false;
if ~any(errtypes==1)
errtypes(end+1)=1;
end
end
else
error('Wrong conditions specified for solution checks.');
end
end
if any(isinf(y(:)))
feas=false;
errtypes(end+1)=2;
end
if any(isnan(y(:)))
feas=false;
errtypes(end+1)=3;
end
if ~isreal(y)
feas=false;
errtypes(end+1)=4;
end
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment