Crating a matrix perpendicular to a decline wall

1 Ansicht (letzte 30 Tage)
ran
ran am 15 Dez. 2023
I have data set of velocity nd temperature on a coragatiion surface and i nead to calculat the perpendicular velocity and temperature. what we want it to crate a matrix like the image, that using the original x and y nwithout rotating them and crate a new matrix of perpendicular location, meaning the first colom will be the start of the declin and all the nurmal locations.every where i look every body rotating the data but i want only rotating the velocity vactors.
i add the locationg vactors for up slop and down slop that u can see what i mean, the velocity i know how to do in the moment i will have the new matx

Antworten (1)

Maneet Kaur Bagga
Maneet Kaur Bagga am 2 Jan. 2024
Hello,
As per my understanding, to calculate the perpendicular velocity and temperature please refer to the following steps below:
  • Calculate the direction vector between the upper and the lower points, which will provide the direction of the surface gradient at each location. Normalize these direction vectors to get the unit normal vectors.
  • Use the unit normal vectors to project the velocity vectors onto the normal direction to find the perpendicular velocity. Similarly, the temperature values can be assigned to the corresponding locations.
Please refer to the code below for reference. The code assumes that the velocity vector is available at each point on the upper boundary and you are looking for a component of this velocity that is perpendicular to the line connecting the upper and lower points. The temperature is assumed to be a scalar value that dosen't change when considering perpendicularly.
% Assuming 'velocity' and 'temperature' are provided as 3263x1x12 arrays.
% 'xn_up', 'yn_up', 'xn_down', 'yn_down' are the coordinates of the points on the upper and lower boundaries.
% Initialize matrices to hold the direction vectors and unit normals
direction_vectors = zeros(3263, 1, 12, 2);
unit_normals = zeros(size(direction_vectors));
% Calculate the direction vectors and unit normals
for i = 1:12 % Loop over the third dimension (assuming it represents different instances)
direction_vectors(:, 1, i, 1) = xn_down(:, 1, i) - xn_up(:, 1, i); % x-component of direction
direction_vectors(:, 1, i, 2) = yn_down(:, 1, i) - yn_up(:, 1, i); % y-component of direction
% Calculate the norms of the direction vectors
norms = sqrt(sum(direction_vectors(:, 1, i, :).^2, 4));
% Normalize the direction vectors to get the unit normal vectors
unit_normals(:, 1, i, :) = direction_vectors(:, 1, i, :) ./ norms;
end
% Assuming 'velocity' is provided as an array with the same shape and represents the velocity at the upper boundary
% Initialize the perpendicular velocity matrix
perpendicular_velocity = zeros(3263, 1, 12);
% Project the velocity onto the normal vectors to find the perpendicular component
for i = 1:12
% Dot product between velocity and unit normal vectors
dot_product = sum(velocity(:, 1, i) .* squeeze(unit_normals(:, 1, i, :)), 2);
perpendicular_velocity(:, 1, i) = dot_product;
end
% Assuming 'temperature' is provided, you can directly use it for the temperature matrix
perpendicular_temperature = temperature; % Assuming temperature is a scalar at each point and does not need projection
Hope this helps!

Kategorien

Mehr zu Display Image finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by