Quiver Plot not plotting all data
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tadgh Cullen
le 11 Juin 2015
Réponse apportée : Star Strider
le 11 Juin 2015
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
0 commentaires
Réponse acceptée
Star Strider
le 11 Juin 2015
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Vector Fields dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!