Rotate output of streamslice fucntion

4 visualizaciones (últimos 30 días)
Ian Garcia
Ian Garcia el 26 de Mayo de 2022
Respondida: Avni Agrawal el 15 de Dic. de 2023
I simulated a problem in a body fixed reference frame but wanted to display the results in a lab fixed reference frame (with the body appearing to rotate and the frame fixed). I'm trying to use the streamslice function in matlab on the rotated data, but it doesn't want to do it on a grid that isn't uniformly aligned on the x-y axis. Is there any way to get streamslice to rotate my flowlines by 45 degrees?
  1 comentario
Shree Charan M L
Shree Charan M L el 9 de Oct. de 2023
Rotating the flow field by 45 degrees before using streamslice might help.
% Assuming u and v are flowline, calculate rotated flowlines
theta = deg2rad(45);
u_rotated = u * cos(theta) - v * sin(theta);
v_rotated = u * sin(theta) + v * cos(theta);

Iniciar sesión para comentar.

Respuestas (1)

Avni Agrawal
Avni Agrawal el 15 de Dic. de 2023
Hi Ian,
I understand you are trying to use streamslice’ function in MATLAB on the rotated data. The ‘streamslice’ function in MATLAB is designed to work with data on a uniformly spaced grid aligned with the axes of the coordinate system. If you need to rotate the flow field by 45 degrees and still use ‘streamslice’, you will have to rotate your data to align with the grid, plot the streamlines, and then apply a visual transformation to rotate the plot.
Here is a simple example of how to rotate a flow field by 45 degrees using the ‘streamslice’function:
% Define the grid
[x, y] = meshgrid(linspace(-1, 1, 20), linspace(-1, 1, 20));
% Define a simple vector field (e.g., a circular pattern)
U = -y;
V = x;
% Define the rotation angle (45 degrees converted to radians)
theta = -45 * (pi / 180);
% Define the rotation matrix
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
% Apply the rotation to the vector field
% Initialize the rotated velocity components
U_rot = zeros(size(U));
V_rot = zeros(size(V));
% Rotate each vector
for i = 1:numel(x)
% Rotate the velocity vector at (x(i), y(i))
v = [U(i); V(i)];
v_rot = R * v;
% Store the rotated components
U_rot(i) = v_rot(1);
V_rot(i) = v_rot(2);
end
% Plot the original streamlines
figure;
subplot(1, 2, 1);
streams = streamslice(x, y, U, V);
set(streams, 'Color', 'b');
title('Original Field');
% Plot the rotated streamlines
subplot(1, 2, 2);
streams_rot = streamslice(x, y, U_rot, V_rot);
set(streams_rot, 'Color', 'r');
title('Rotated Field');
Please refer to the following documentation page for more information on the streamslice’ function: https://www.mathworks.com/help/matlab/ref/streamslice.html
I hope this helps.

Categorías

Más información sobre Waves en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by