Ploting streamline with vector's module on line.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
% when using :
streamline(Velocity_x_1,Velocity_y_1,linspace(1,Nx,Ny),linspace(1,1,Ny));
hold on
streamline(Velocity_x_1,Velocity_y_1,linspace(1,Nx,Ny),linspace(Ny,Ny,Ny));
hold on
streamline(Velocity_x_1,Velocity_y_1,linspace(1,1,Ny),linspace(1,Ny,Ny));
hold on
streamline(Velocity_x_1,Velocity_y_1,linspace(Nx,Nx,Ny),linspace(1,Ny,Ny));
hold on
% I plot the streamline of the fluid field by 4 sides of the field.
% however, the result are not good of course.
% Since I have no knowledge of the field, I didn't know how to draw the
% effective streamline by this function. And I also want to know how to add
% the module of the vectors on streamlines just like the contourlines in
% geography textbooks. Thanks a lot!
% the result is:

% what I want is like:

% But with direction like vector lines.
2 comentarios
Respuesta aceptada
Sam Chak
el 19 de Oct. de 2023
Hi @泽江
Can you check if the following are what you want?
spacing = 0.2;
x = -2:spacing:2;
y = -2:spacing:2;
[X, Y] = meshgrid(x,y);
Z = X .* exp(-X.^2 - Y.^2);
figure(1)
level = 10;
contour(X, Y, Z, level, 'ShowText', 'on')
figure(2)
[DX,DY] = gradient(Z, spacing);
quiver(X, Y, DX, DY), axis([-2 2 -2 2])
figure(3)
contour(X, Y, Z, level, 'ShowText', 'on'), hold on
quiver(X, Y, DX, DY), axis([-2 2 -2 2])
7 comentarios
Sam Chak
el 21 de Oct. de 2023
No worries @泽江. You can show what you've plotted using the contour/quiver approach and then share your expectations with us. The plotting features in MATLAB are highly customizable. However, my plotting skills are only so-so. Perhaps @Dyuman Joshi can provide advice and a solution in his answer.
Considering the density of lines, I can imagine your data is quite big. Nevertheless, you can extract a portion of the data, say 20% to 30%. Here's an example of how to extract 10% of the data. We're looking forward to seeing Velocity_x_new and Velocity_y_new.
% Original Data with 101 points
x = linspace(0, 10, 101);
y = x.^2;
plot(x, y, '.'), hold on
% Extract 10% from the data
percent = 10;
stepSize = percent/100*(numel(x) - 1)
xNew = x(1:stepSize:end)
c = ismember(x, xNew); % check if Set xNew is a subset of Set x
idx = find(c); % find indices of the subset ⊂
yNew = y(idx)
plot(xNew, yNew, 'o', 'MarkerSize', 11, 'LineWidth', 2), grid on
xlabel('x'), ylabel('y')
Más respuestas (0)
Ver también
Categorías
Más información sobre Language Support en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




