% readgr01a-r8.m
% plots the raster-image scan01b.raw with a gray scale pallette
% need to add lines of path and flux vectors.

FID = fopen('gr01a-r8.raw','r');

[A,count] = fread(FID,[300,300],'char');
B=rot90(flipud(A),3);
CLF;
figure(1);
reset(GCF);
WHITEBG('w');
pcolor(B);
colormap(gray);

% linear estimation of vector-origin paths
% parameters slope = b; a, c are x any y origins (a,c).
a = 257;
b = 3.7;
c = 130;

% estimate vertices of path #3
x1 = c - b*(0);
x2 = c - b*(-6);
x3 = c - b*(-9.6);
x4 = c - b*(-13.2);
x5 = c - b*(-14);
x6 = c - b*(-15.2);
x7 = c - b*(-16);
x8 = c - b*(-16);
x9 = c - b*(-16);
x10 = c - b*(-16);
x11 = c - b*(-44);
x12 = c - b*(-16);
x13 = c - b*(-12);
x14 = c - b*(-8);
x15 = c - b*(-6.4);
x16 = c - b*(-6);
x17 = c - b*(-5.6);
x18 = c - b*(-4.4);
x19 = c - b*(-2.8);
x20 = c - b*(2);
x21 = c - b*(6.8);

y1 = a - b*(0) ;
y2 = a - b*(1.2);
y3 = a - b*(3.6);
y4 = a - b*(5.6);
y5 = a - b*(8);
y6 = a - b*(10);
y7 = a - b*(12.4);
y8 = a - b*(16.4);
y9 = a - b*(20);
y10 = a - b*(22.4);
y11 = a - b*(22.4);
y12 = a - b*(22.4);
y13 = a - b*(30.4);
y14 = a - b*(36.4);
y15 = a - b*(38.4);
y16 = a - b*(41.6);
y17 = a - b*(44);
y18 = a - b*(46.4);
y19 = a - b*(50);
y20 = a - b*(53.6);
y21 = a - b*(55.6);

x = [x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13];
y = [y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13];

junk = box(x1,y1,2);
junk = box(x2,y2,2);
junk = box(x3,y3,2);
junk = box(x4,y4,2);
junk = box(x5,y5,2);
junk = box(x6,y6,2);
junk = box(x7,y7,2);
junk = box(x8,y8,2);
junk = box(x9,y9,2);
junk = box(x10,y10,2);
junk = box(x11,y11,2);
junk = box(x12,y12,2);
junk = box(x13,y13,2);
junk = box(x14,y14,2);
junk = box(x15,y15,2);
junk = box(x16,y16,2);
junk = box(x17,y17,2);
junk = box(x18,y18,2);
junk = box(x19,y19,2);
junk = box(x20,y20,2);
junk = box(x21,y21,2);

% line(x,y); do not plot the probe path!
% hold;
% now add vectors of path #3
d = 4.0;
v1 = x1 + d* ( 3.300243008 );
v2 = x2 + d* ( 3.86940458 );
v3 = x3 + d* ( 4.021704677 );
v4 = x4 + d* ( 1.935462074 );
v5 = x5 + d* ( -8.19893748 );
v6 = x6 + d* ( -4.37608136 );
v7 = x7 + d* ( -8.273634479 );
v8 = x8 + d* ( -8.457216973 );
v9 = x9 + d* ( -0.909729114 );
v10 = x10 + d* ( 2.646952602 );
v11 = x11 + d* ( -1.019722377 );
v12 = x12 + d* ( -3.219761209 );
v13 = x13 + d* ( -3.123766734 );
v14 = x14 + d* ( -5.746923654 );
v15 = x15 + d* ( -8.601565946 );
v16 = x16 + d* ( -5.89412855 );
v17 = x17 + d* ( -2.246920439 );
v18 = x18 + d* ( -4.423272394 );
v19 = x19 + d* ( -4.375443682 );
v20 = x20 + d* ( -5.182294703 );
v21 = x21 + d* ( -0.099644473 );



w1 = y1 + d* ( -1.186035495 );
w2 = y2 + d* ( 5.093587205 );
w3 = y3 + d* ( -3.665075966 );
w4 = y4 + d* ( -1.372668869 );
w5 = y5 + d* ( -6.81315867 );
w6 = y6 + d* ( -6.481574316 );
w7 = y7 + d* ( -8.581585952 );
w8 = y8 + d* ( -6.770813268 );
w9 = y9 + d* ( -4.218606341 );
w10 = y10 + d* ( -4.172714566 );
w11 = y11 + d* ( -0.796607514 );
w12 = y12 - d* ( -1.348622949 );
w13 = y13 - d* ( -1.570787709 );
w14 = y14 - d* ( -2.798450491 );
w15 = y15 - d* ( -7.630799209 );
w16 = y16 - d* ( -5.72004869 );
w17 = y17 - d* ( -0.576146414 );
w18 = y18 - d* ( -2.37188271 );
w19 = y19 - d* ( -4.176538676 );
w20 = y20 - d* ( -2.255799688 );
w21 = y21 - d* ( -2.474673486 );

% add 10 uF per ... bar
line([20 20+d*10],[290 290]);

line([x1 v1],[y1 w1]);
line([x2 v2],[y2 w2]);
line([x3 v3],[y3 w3]);
line([x4 v4],[y4 w4]);
line([x5 v5],[y5 w5]);
line([x6 v6],[y6 w6]);
line([x7 v7],[y7 w7]);
line([x8 v8],[y8 w8]);
line([x9 v9],[y9 w9]);
line([x10 v10],[y10 w10]);
line([x11 v11],[y11 w11]);
line([x12 v12],[y12 w12]);
line([x13 v13],[y13 w13]);
line([x14 v14],[y14 w14]);
line([x15 v15],[y15 w15]);
line([x16 v16],[y16 w16]);
line([x17 v17],[y17 w17]);
line([x18 v18],[y18 w18]);
line([x19 v19],[y19 w19]);
line([x20 v20],[y20 w20]);
line([x21 v21],[y21 w21]);

axis([-17 317 -17 317]), axis('ij'), axis('image'), axis('off'), shading('flat');
