bzr branch
http://suren.me/webbzr/normxcorr/trunk
1
by Suren A. Chilingaryan
Initial import |
1 |
function line_visual(filenamelist,raw_peak_results,int_width_y_mark); |
2 |
||
3 |
%"Stand alone" code to visualize DIC .dat results files
|
|
4 |
%Programmed by Rob slightly changed by Chris
|
|
5 |
%Last revised: 2//06
|
|
6 |
||
7 |
||
8 |
%Load the necessary files
|
|
9 |
||
10 |
if exist('filenamelist')==0 |
|
11 |
load('filenamelist') |
|
12 |
end
|
|
13 |
if exist('raw_peak_results')==0 |
|
14 |
load('raw_peak_results.dat') |
|
15 |
end
|
|
16 |
if exist('int_width_y_mark')==0 |
|
17 |
load('int_width_y_mark.dat') |
|
18 |
end
|
|
19 |
||
20 |
%Number of images to analyze is r; also initialize xpos, y_mark
|
|
21 |
||
22 |
[r,c]=size(filenamelist); |
|
23 |
xpos_o=raw_peak_results(1,:); |
|
24 |
y_mark=int_width_y_mark(2,1); |
|
25 |
||
26 |
%Start analysis of results
|
|
27 |
||
28 |
g=waitbar(0,'Processing the results...'); |
|
29 |
||
30 |
for m=2:(r-1) |
|
31 |
||
32 |
%Calculate displacements and engineering strains (i.e. average strains between
|
|
33 |
%the two selected points...similar to an ISDG measurement)
|
|
34 |
||
35 |
waitbar(m/(r-1)); |
|
36 |
warning off MATLAB:divideByZero |
|
37 |
||
38 |
xdis=raw_peak_results(m,:)-xpos_o; |
|
39 |
epsxx=(xdis(2)-xdis(1))/(xpos_o(2)-xpos_o(1)); |
|
40 |
||
41 |
epsxx_plot(1)=0; |
|
42 |
epsxx_plot(m+1)=epsxx*100; |
|
43 |
||
44 |
%Initialize and then save displacement and strain field data for each image
|
|
45 |
||
46 |
xdis_all(m,:)=xdis; |
|
47 |
epsxx_all(m)=epsxx; |
|
48 |
end
|
|
49 |
||
50 |
epsxx_all=epsxx_all';
|
|
51 |
||
52 |
close(g)
|
|
53 |
||
54 |
save disp_x.dat xdis_all -ascii -tabs
|
|
55 |
save strain_x.dat epsxx_all -ascii -tabs
|
|
56 |
||
57 |
%Show user strain vs. image number plot and save the data and figure
|
|
58 |
||
59 |
l=figure;
|
|
60 |
plot(1:r,epsxx_plot,'.-b')
|
|
61 |
axis([1 (max(r)*1.1) 0 (max(epsxx_plot)*1.1)])
|
|
62 |
xlabel('Image Number (Image #1 defined to be the very first image loaded for analysis)') |
|
63 |
ylabel('Engineering Strain [%]') |
|
64 |
title('Engineering Strain vs. Image Number') |
|
65 |
||
66 |
strain_image_data_x=[(1:r)' epsxx_plot']; |
|
67 |
save strain_image_x.txt strain_image_data_x -ascii -tabs
|
|
68 |
saveas(l,'strain_image_x.fig')
|
|
69 |
||
70 |
%Ask user if a full-figure stress vs. strain plot is desired; save data and figure too
|
|
71 |
||
72 |
plot_selection = menu(sprintf('The displacement and strain values from each image have been saved and plotted.\n An Eng Stress vs. Eng Strain curve can now be generated if the files "time_stress.txt" (raw data from Labview, stress values in [MPa]) and "time_image.txt" (saved by AutoIt)\n are available in the image directory. Matlab will sort through these files and select the correct stress value for a given image and calculated strain using system time as the reference.\n (Note: The matching logic used in this step to correlate the stress and strain values requires that the raw data aquisition rate be at least 2 data points per second.)\n Click "Generate Plot" to do this or click "Exit" to quit Matlab.'),'Generate Plot','Exit'); |
|
73 |
||
74 |
if plot_selection == 1
|
|
75 |
|
|
76 |
stress_strain_match
|
|
77 |
|
|
78 |
n=figure;
|
|
79 |
plot(epsxx_plot,stress_image(:,2),'.-b')
|
|
80 |
axis([0 (max(epsxx_plot)*1.1) 0 (max(stress_image(:,2))*1.1)])
|
|
81 |
xlabel('Engineering Strain [%]') |
|
82 |
ylabel('Engineering Stress [MPa]') |
|
83 |
title('Engineering Stress vs. DIC Engineering Strain') |
|
84 |
|
|
85 |
stress_strain_data_x=[epsxx_plot' stress_image(:,2)]; |
|
86 |
save stress_strain_x.txt stress_strain_data_x -ascii -tabs |
|
87 |
saveas(n,'stress_strain_x.fig') |
|
88 |
||
89 |
elseif plot_selection == 2 |
|
90 |
return
|
|
91 |
end
|
|
92 |
||
93 |
%Ask user if a figure with two subplots is desired...good for presentation animations
|
|
94 |
||
95 |
plot_selection2 = menu(sprintf('A figure with two subplots can now be generated for use in animated presentations.\n (Caution: The .avi movie saved in this step can become very large depending on the number of images analyzed.)\n Click "Generate Subplots" to do this or click "Exit" to quit Matlab.'),'Generate Subplots','Exit'); |
|
96 |
||
97 |
if plot_selection2 == 1 |
|
98 |
||
99 |
%Define counter for image capture and load stress data
|
|
100 |
||
101 |
mov_count=0; |
|
102 |
||
103 |
for M=1:r |
|
104 |
||
105 |
subplot(2,1,1) |
|
106 |
imshow(filenamelist(M,:)) |
|
107 |
hold on |
|
108 |
plot(raw_peak_results(1,1),y_mark,'xr','markersize',10) %,'markersize',12 |
|
109 |
plot(raw_peak_results(1,2),y_mark,'xr','markersize',10) |
|
110 |
||
111 |
if M > 1 |
|
112 |
||
113 |
plot(raw_peak_results(M,1),y_mark,'xg','markersize',10) |
|
114 |
plot(raw_peak_results(M,2),y_mark,'xg','markersize',10) |
|
115 |
end
|
|
116 |
||
117 |
title(['Image Correlation Results',sprintf(' (Current image: %10s)',filenamelist(M,:))],'fontweight','bold')
|
|
118 |
drawnow
|
|
119 |
hold off |
|
120 |
||
121 |
subplot(2,1,2) |
|
122 |
hold on |
|
123 |
plot(epsxx_plot(M),mov_stress(M),'og') |
|
124 |
box on |
|
125 |
axis([0 (max(epsxx_plot)*1.1) 0 (max(mov_stress)*1.1)]) |
|
126 |
xlabel('Engineering Strain [%]','fontsize',8,'fontweight','bold') |
|
127 |
ylabel('Engineering Stress [MPa]','fontsize',8,'fontweight','bold') |
|
128 |
title('Engineering Stress vs. DIC Engineering Strain','fontweight','bold') |
|
129 |
drawnow
|
|
130 |
hold off |
|
131 |
||
132 |
||
133 |
end
|
|
134 |
||
135 |
elseif plot_selection2 == 2 |
|
136 |
return
|
|
137 |
end
|
|
138 |
||
139 |
||
140 |