Quiver Plot not plotting all data

5 次查看(过去 30 天)
Hi, I've created code to demonstrate a simple rankine vortex and initially I thought my code was wrong but I have since done the problem in excel, imported it to MATLAB and still the graph I am getting showing is omitting the majority of the data. I'm using a quiver plot and would expect arrows for every point on the grid.
I have pasted below the code to import the text file with the data inside (attached). I have also attached the plot I get and what I expect to get (roughly). I would really really appreciate any help. Thanks in advance
filename = 'C:\Users\TC\Documents\MATLAB\Free_Forced_Vorticity\ExcelOutput.txt';
delimiter = '\t';
formatSpec = '%f%f%f%f%f%f%f%f%[^\n\r]';
%%Open the text file.
fileID = fopen(filename,'r');
%%Read columns of data according to format string.
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'ReturnOnError', false);
%%Close the text file.
fclose(fileID);
%%Allocate imported array to column variable names
i = dataArray{:, 1};
j = dataArray{:, 2};
x = dataArray{:, 3};
y = dataArray{:, 4};
r = dataArray{:, 5};
utheta = dataArray{:, 6};
u = dataArray{:, 7};
v = dataArray{:, 8};
%%Clear temporary variables
clearvars filename delimiter formatSpec fileID dataArray ans;
%%Graphing Data
quiver(x,y,u,v)
grid on

采纳的回答

Star Strider
Star Strider 2015-6-11
They’re all plotted, but they vary considerably in length so some don’t show up. If you artificially normalise them, they all do.
Without changing any of your other code, replace the ‘quiver’ call with this to see them:
arwlen = hypot(u, v); % Arrow Lengths
figure(1)
quiver(x, y, u./arwlen, v./arwlen);
grid
Apparently, Excel (or whatever you plotted ‘Expected Graph’ with) doesn’t care about the length variation. MATLAB does.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by