Issue plotting streamlines (input in ascending order)
3 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am having an issue plotting some streamlines. I get an error when I attempt to plot my streamlines because it uses interp1 and one of my inputs to streamline is not in "ascending order". I have attached my code and data file. The streamlines should be going from left to right like the vectors in the quiver plot.
Quiver plot looks like this:
Error message is this:
What do I need to do with the inputs to streamline() to makes this work properly?
clc;clear;close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Set plot stuff:
set(0,'DefaultLineLineWidth',1.5)
% set(0,'DefaultLineColor',[1,1,1])
set(0,'DefaultLineMarkerSize',15)
set(0,'DefaultAxesFontSize',20)
set(0,'DefaultFigureColor',[1,1,1])
set(0,'DefaultTextFontSize',18)
% set(0,'DefaultTextInterpreter','latex')
set(0,'DefaultTextFontName','Times-Roman')
set(0,'DefaultAxesFontName','Times-Roman')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
runname = 'M.25_0Y_A';
%% Load data
load(['final_data_run1.mat'])
Uavg(Uavg==0) = NaN; % Set null data to NaN
Vavg(Vavg==0) = NaN; % Set null data to NaN
Xi = sort(X(:,1));
Yi = sort(Y(1,:))';
%% Create the combination of xq and yq
[Xq, Yq] = meshgrid(Xi,Yi);
% Interp the data if the x and y data in the file is not in a grid
Uq = rot90(Uavg);
Vq = rot90(Vavg);
%% probe walls (Need rotate these eventually)
ytip = 4.18-1; % Bottom left vertice of left probe wall
xtip = -7.703; % Bottom left vertice of left probe wall
width = 12.7; % mm
height = 1; % mm
gap = 3; % mm - Distance between probe walls (left end of the walls)
%% New coordinates (origin will be at hte probe tip)
xcenter = xtip; % X-center point of probe tip
ycenter = ytip-height; % Y-center point of probe tip
xtip = xtip-xcenter; % Bottom left vertice of left probe wall
ytip = ytip-ycenter; % Bottom left vertice of left probe wall
Xq = Xq+ycenter;
Yq = Yq-xcenter;
%% Plot vectors, probe walls, and streamlines
fig = figure('Renderer', 'painters', 'Position', [1300 10 947 900])
quiver(Yq,-Xq,Vq,-Uq, 1);%, 'LineWidth',2) % Plot vectors
hold on;
yline(0);xline(0); hold on % Plots probe centerlines
l = title({'test_line'}, 'Interpreter', 'none');
title(['Averaged Velocities and Streamlines (',runname,')'])
% % Plot probe walls
rectangle('Position',[xtip,ytip,width,height],'FaceColor','k')
rectangle('Position',[xtip,ytip-gap,width,height],'FaceColor','k')
xlabel('x (mm)')
ylabel('y (mm)')
s = 0.10;
starty = -2.5:s:2.5;
startx = (min(min(Yq))+.25)*ones(size(starty));
%% Plot Streamlines
% hgridinterp = streamline(Yq,Xq,Vq,Uq,startx,starty); hold on;
hgridinterp = streamline(Yq,-Xq,Vq,-Uq,startx,starty); hold on;
set(hgridinterp,'color','red','linewidth',3);
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!