annotate findFieldWidth.m @ 87:0a29a60e0b21

In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
author Martin Almquist <martin.almquist@it.uu.se>
date Sun, 29 Nov 2015 22:23:09 +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