MATLAB Answers


This question is closed. Reopen it to edit or answer.

How to Rotate a pcolor plot 20 degrees

1 view (last 30 days)
Addison Collins
Addison Collins on 28 Jun 2021
Closed: Matt J on 30 Jun 2021
Hello all,
I have taken velocity data from a PIV experiment with a probe at 2 angles, 0 degrees and 20 degrees (see photos). It is easy to evaluate the plots when the probe entrace is 0 degrees. For the cases in which the probe is 20 degrees, I would like to rotate the data such that It is as if I am viewing it at 0 degrees. It makes it easier for me to analyze the velocity datas. I am not confident in my abilities with rotation matrices to do this correctly (if that is even the correct approach). I have attached my code and the data file (.mat).
The probe and data left of the probe is masked out because the data is bad (just part of the PIV process).
EDIT::: I should have clarified this. The probe rotates approximately about the center of its tip. In the first photo you can see the tip is parallell to the horizontal black line I drew. in the second figure you can see it intesects the probe tip. I believe it will have to be rotated about the intsersection of the probe tip and the black line.
The .mat I provided is the data for the second photo.
probe at 0 degrees: The black line represents the velocities I am plotting. The vertical red lines represent the outter wall position and the blue lines represent the inside of the probe walls.
probe at 20 degrees: Note that the probe is masked out. it is 4 mm in width and it is clear where the end is (look at the blue-green velocities near the black line)
% In summary this code:
% 1) Removes the NaN points in the raw MATLAB file.
% 2) Finds wall and offsets the data to set the wall as the new origin.
% 3) Removes spurious points from data using the random uncertainty output
% by DaVis; removes points that are >2*sigma in uncertainty
% 4) Saves the U, V, X, and Y (variables subscript as _Wall) to a .mat
% file
%% ****** Set the Formatting *****
clear; clc; close all;
close all;
%% ******* Flow Conditions *******
Rey = 1;
anglStr = {'1'};
panel = {'1'};
nfiles = 1; % Number of .dat files ASC added
%% Load the File
for p = 1:length(panel)
for a = 1:length(anglStr)
%% ------------- Remove NaN Points from Raw Data ------------------
U(U==0) = NaN; % Set null data to NaN
V(V==0) = NaN; % Set null data to NaN
% V(V<<0) = NaN; % Set null data to NaN
% Find where entire rows/columns are null and remove them
Utemp = nanmean(U,3);
Urow = nanmean(Utemp,1);
Ucol = nanmean(Utemp,2);
notNanCol = find(~isnan(Urow));
notNanRow = find(~isnan(Ucol));
U_Clean = U(notNanRow, notNanCol,:);
V_Clean = V(notNanRow, notNanCol,:);
X_Clean = X(notNanRow, notNanCol);
Y_Clean = Y(notNanRow, notNanCol);
% Y direction ASC
mult = 2.3;
close all
locationx = 123;
locationy = 145;
% figure('Position', [1285 0 mult*560 mult*420])
% subplot(2,2,1)
% plot(Y(locationy,:),V(locationy,:))
% xlabel('Y-position (mm)')
% ylabel('Stream-wise veloctity (m/s)')
% ylim([-5 90])
% subplot(2,2,2)
% pcolor(X,Y,V); hold on;
% shading interp
% colorbar
% caxis([0 90])
% plot(X(locationy,:),Y(locationy,:),'linewidth',2,'color','k')
% xlabel('mm')
% ylabel('mm')
% X direction ASC
figure('Position', [630 35 mult*560 mult*420])
% subplot(2,2,3)
title('Steamwise Velocity (V-component)')
xlabel('X-position (mm)')
ylabel('Stream-wise veloctity (m/s)')
Lwall = -4.182; Rwall = 0.1648;
ylim([-5 90])
% subplot(2,2,4);
pcolor(X,Y,V); hold on;
shading interp
caxis([0 90])
title('Steamwise Velocity vs X-position')
% colormap('jet');
axis equal
%% probe velocity calculation
% Finding indices of values at probe tip USES locationx
Xvec = X(:,locationx);
indices = find(Xvec>Lwall & Xvec<Rwall);
Xvec = Xvec(indices(1):indices(end));
Vvec = V(:,locationx);
Vvec = Vvec(indices(1):indices(end));
Vavg = mean(Vvec);
fprintf('Average probe tip velocity = %0.2f m/s\nVia diameter calc\n\n',Vavg)
dx = abs(Xvec(end-1)-Xvec(end));
r = (0:dx:1)';
A = zeros(length(r),1);
Atot = pi*1^2;
Vvec_append = Vvec(round(length(indices)/2+1):round(length(indices)/2+length(r)));
% Weighted velocity averages
for j = 2:length(r)
A(j) = pi*(r(j)^2-r(j-1)^2); % Annular areas of probe for # of r points
A_weight = A/Atot;
A_weight(1) = 0.0434; % Given to the center velocity
V_weight = (Vvec_append.*A_weight);
Vavg = sum(V_weight)/sum(A_weight);
fprintf('Average velocity across provbe INLET area = %.0f m/s\n',Vavg)
Addison Collins
Addison Collins on 29 Jun 2021
The point of rotation should be (-2.117, -8.053)

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by