Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
catchment-eco-hydro
Virtual_catchment_transient_ages
Commits
c1fe17e4
Commit
c1fe17e4
authored
Jan 24, 2020
by
Nicolas Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
a64cca45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
checksol.m
checksol.m
+56
-0
No files found.
checksol.m
0 → 100644
View file @
c1fe17e4
%
% 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment