annotate findFieldWidth.m @ 1031:2ef20d00b386 feature/advectionRV

For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Jan 2019 10:25:06 +0100
parents 30ae48efc7ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
1 % Calculates the maximum field width needed width fprintf for a given format fmt for the values in A
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
2 % A = [1.13232 10.233 1.1];
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
3 % width = findFieldWidth('%.2f',A);
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
4 % Gives wdith = 5
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
5 function width = findFieldWidth(fmt, A)
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
6 width = 0;
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
7 for i = 1:numel(A)
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
8 elem = A(i);
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
9 if iscell(elem)
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
10 elem = elem{1};
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
11 end
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
12 str = sprintf(fmt,elem);
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
13 width = max(width,length(str));
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
14 end
30ae48efc7ae Added utility function findFiledWidth. Added function for calculating and saving solutions.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
15 end