Quiver Plot not plotting all data

조회 수: 7 (최근 30일)
Tadgh Cullen
Tadgh Cullen 2015년 6월 11일
답변: Star Strider 2015년 6월 11일
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에서 Vector Fields에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by