annotate findFieldWidth.m @ 679:247b58a4dbe8 feature/poroelastic

Add support for Dirichlet and Traction BC on different components at the same boundary. Remove some unused variables and improve comments.
author Martin Almquist <malmquist@stanford.edu>
date Mon, 05 Feb 2018 14:45:26 -0800
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