1 clc; clear; close all; % Clear command window, workspace, and close all figures
  2 casePath = '..'; % Define the relative path to the case directory
  3 load(fullfile(casePath, 'figure_data', 'u_stat.mat')); % Load statistical data for plotting
  4 
  5 %% Plot lines
  6 % Plot 1: Double average velocity (U) along the vertical line
  7 figure(1); scatter(U_xt, Y); % Scatter plot of U_xt vs Y
  8 set(xlabel("$U(\rm m/s)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
  9 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 10 set(gca, 'YScale', 'log'); % Set y-axis to logarithmic scale
 11 print(gcf, fullfile('..', 'analysis_figures', 'U_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 12 saveas(gcf, fullfile('..', 'analysis_figures', 'U_vs_Y.fig')); % Save plot as .fig
 13 saveas(gcf, fullfile('..', 'analysis_figures', 'U_vs_Y.svg')); % Save plot as .svg
 14 print(gcf, fullfile('..', 'analysis_figures', 'U_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 15 
 16 % Plot 2: Double average velocity (V) along the vertical line
 17 figure(2); scatter(V_xt, Y); % Scatter plot of V_xt vs Y
 18 set(xlabel("$V(\rm m/s)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 19 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 20 print(gcf, fullfile('..', 'analysis_figures', 'V_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 21 saveas(gcf, fullfile('..', 'analysis_figures', 'V_vs_Y.fig')); % Save plot as .fig
 22 saveas(gcf, fullfile('..', 'analysis_figures', 'V_vs_Y.svg')); % Save plot as .svg
 23 print(gcf, fullfile('..', 'analysis_figures', 'V_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 24 
 25 % Plot 3: Reynolds shear stress (RSS) along the vertical line
 26 figure(3); scatter(RSS, Y); % Scatter plot of RSS vs Y
 27 set(xlabel("$-\overline{u'v'}(\rm m^2/s^2)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 28 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 29 print(gcf, fullfile('..', 'analysis_figures', 'RSS_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 30 saveas(gcf, fullfile('..', 'analysis_figures', 'RSS_vs_Y.fig')); % Save plot as .fig
 31 saveas(gcf, fullfile('..', 'analysis_figures', 'RSS_vs_Y.svg')); % Save plot as .svg
 32 print(gcf, fullfile('..', 'analysis_figures', 'RSS_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 33 
 34 % Plot 4: Turbulent normal stress (uu) along the vertical line
 35 figure(4); scatter(uu_xt, Y); % Scatter plot of uu_xt vs Y
 36 set(xlabel("$\overline{u'u'}(\rm m^2/s^2)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 37 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 38 print(gcf, fullfile('..', 'analysis_figures', 'uu_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 39 saveas(gcf, fullfile('..', 'analysis_figures', 'uu_vs_Y.fig')); % Save plot as .fig
 40 saveas(gcf, fullfile('..', 'analysis_figures', 'uu_vs_Y.svg')); % Save plot as .svg
 41 print(gcf, fullfile('..', 'analysis_figures', 'uu_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 42 
 43 % Plot 5: Turbulent normal stress (vv) along the vertical line
 44 figure(5); scatter(vv_xt, Y); % Scatter plot of vv_xt vs Y
 45 set(xlabel("$\overline{v'v'}(\rm m^2/s^2)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 46 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 47 print(gcf, fullfile('..', 'analysis_figures', 'vv_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 48 saveas(gcf, fullfile('..', 'analysis_figures', 'vv_vs_Y.fig')); % Save plot as .fig
 49 saveas(gcf, fullfile('..', 'analysis_figures', 'vv_vs_Y.svg')); % Save plot as .svg
 50 print(gcf, fullfile('..', 'analysis_figures', 'vv_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 51 
 52 % Plot 6: Root mean square of velocity fluctuations (u_rms) along the vertical line
 53 figure(6); scatter(u_rms, Y); % Scatter plot of u_rms vs Y
 54 set(xlabel("$u_{rms}(\rm m/s)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 55 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 56 print(gcf, fullfile('..', 'analysis_figures', 'u_rms_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 57 saveas(gcf, fullfile('..', 'analysis_figures', 'u_rms_vs_Y.fig')); % Save plot as .fig
 58 saveas(gcf, fullfile('..', 'analysis_figures', 'u_rms_vs_Y.svg')); % Save plot as .svg
 59 print(gcf, fullfile('..', 'analysis_figures', 'u_rms_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 60 
 61 % Plot 7: Root mean square of velocity fluctuations (v_rms) along the vertical line
 62 figure(7); scatter(v_rms, Y); % Scatter plot of v_rms vs Y
 63 set(xlabel("$v_{rms}(\rm m/s)$", "FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 64 set(ylabel("$y(\rm m)$", "FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 65 print(gcf, fullfile('..', 'analysis_figures', 'v_rms_vs_Y.emf'), '-dmeta', '-r300'); % Save plot as .emf
 66 saveas(gcf, fullfile('..', 'analysis_figures', 'v_rms_vs_Y.fig')); % Save plot as .fig
 67 saveas(gcf, fullfile('..', 'analysis_figures', 'v_rms_vs_Y.svg')); % Save plot as .svg
 68 print(gcf, fullfile('..', 'analysis_figures', 'v_rms_vs_Y.jpg'), '-djpeg', '-r300'); % Save plot as .jpg
 69 saveas(gcf, fullfile('..', 'analysis_figures', 'v_rms_vs_Y.svg')); % Save plot as .svg
 70 
 71 % %% Plot fields (commented out)
 72 % 
 73 % figure(8)
 74 % imagesc(X,Y, U_t); % Plot 2D field of U_t
 75 % set(gca,'YDir','normal'); % Set y-axis direction to normal
 76 % set(xlabel("$x/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 77 % set(ylabel("$y/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 78 % c = colorbar; % Add colorbar
 79 % c.Label.String = '$\overline{U}/\rm m/s$'; % Set colorbar label
 80 % c.Label.Interpreter = 'latex'; % Use LaTeX formatting for colorbar label
 81 % c.Label.FontSize = 14; % Set font size for colorbar label
 82 % % hold on;
 83 % % h1 = quiver(data.x{1, 1}, flip(data.y{1, 1}), flip(U_t), zeros(size(V_t))); % Add quiver plot (commented out)
 84 % % set(h1, 'AutoScale', 'on', 'AutoScaleFactor', 5); % Configure quiver plot scaling
 85 % 
 86 % figure(9)
 87 % imagesc(X,Y,V_t); % Plot 2D field of V_t
 88 % set(gca,'YDir','normal'); % Set y-axis direction to normal
 89 % set(xlabel("$x/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
 90 % set(ylabel("$y/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
 91 % c = colorbar; % Add colorbar
 92 % c.Label.String = '$\overline{V}/\rm m/s$'; % Set colorbar label
 93 % c.Label.Interpreter = 'latex'; % Use LaTeX formatting for colorbar label
 94 % c.Label.FontSize = 14; % Set font size for colorbar label
 95 % 
 96 % figure(10)
 97 % imagesc(X,Y, V_t); % Plot 2D field of V_t (duplicate of figure 9)
 98 % set(gca,'YDir','normal'); % Set y-axis direction to normal
 99 % set(xlabel("$x/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
100 % set(ylabel("$y/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
101 % c = colorbar; % Add colorbar
102 % c.Label.String = '$\overline{V}/\rm m/s$'; % Set colorbar label
103 % c.Label.Interpreter = 'latex'; % Use LaTeX formatting for colorbar label
104 % c.Label.FontSize = 14; % Set font size for colorbar label
105 % 
106 % figure(11)
107 % imagesc(X,Y,sqrt(U_t.*U_t + V_t.*V_t)); % Plot 2D field of velocity magnitude
108 % set(gca,'YDir','normal'); % Set y-axis direction to normal
109 % set(xlabel("$x/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set x-axis label with LaTeX formatting
110 % set(ylabel("$y/\rm m$","FontSize", 14), 'Interpreter', 'latex'); % Set y-axis label with LaTeX formatting
111 % c = colorbar; % Add colorbar
112 % c.Label.String = '$\sqrt{\overline{U}^2+\overline{V}^2}/\rm m/s$'; % Set colorbar label
113 % c.Label.Interpreter = 'latex'; % Use LaTeX formatting for colorbar label
114 % c.Label.FontSize = 14; % Set font size for colorbar label
115