Error in function streamline: interp1 sample points must be unique.
48 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I have to display the streamlines of a supersonic flow around a cone. I have the meshgrid and the speed components in this fashion
x = [ 0, 0.333333333333333, 0.666666666666667, 1.00000000000000;...
0, 0.332271622840308, 0.664543245680615, 0.996814868520923;...
0, 0.331377263507562, 0.662754527015124, 0.994131790522686;...
0, 0.331191240165995, 0.662382480331990, 0.993573720497985];
y = [0, 0.0587561394208747, 0.117512278841749, 0.176268418262624;...
0, 0.0644900278013948, 0.128980055602790, 0.193470083404184;...
0, 0.0689384091852737, 0.137876818370547, 0.206815227555821;...
0, 0.0698266243496454, 0.139653248699291, 0.209479873048936];
Vx = 1.0e+03.* [ 2.9768 2.9856 2.9926 2.9941;...
2.9768 2.9856 2.9926 2.9941;...
2.9768 2.9856 2.9926 2.9941;...
2.9768 2.9856 2.9926 2.9941];
Vy = [524.7211 524.7211 524.7211 524.7211;...
477.1746 477.1746 477.1746 477.1746;...
442.4958 442.4958 442.4958 442.4958;...
435.4701 435.4701 435.4701 435.4701];
The quiver plot works nicely, but when I have to show streamlines I get this error
figure();
plot(x,y,'.k')
hold on;
streamline(x,y,Vx, Vy, zeros(1,4), zeros(1,4));
Error using matlab.internal.math.interp1
Sample points must be unique.
Error in interp1 (line 188)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in stream2 (line 63)
syi=interp1(yy(:),1:szu(1),sy(k));
Error in streamline (line 62)
verts = stream2(x,y,u,v,sx,sy,options);
Error in cuneo_vs_cono (line 65) (<--- this is the script name I am working on)
streamline(x,y,Vx, Vy, zeros(1,4), zeros(1,4));
I have attempted also with different starting points but I get always and always the same error. Maybe some errors in using them?
Thank you.
0 comentarios
Respuestas (2)
Benjamin Kraus
el 7 de Mzo. de 2023
Editada: Benjamin Kraus
el 7 de Mzo. de 2023
The issue you are having is the form of your X and Y data you are providing as input to streamline. The streamline doc page says (regarding the X input): "x-axis coordinates of vector data, specified as a 2-D or 3-D array that can be combined with Y (and optionally Z) to form a grid of coordinates. You can use the meshgrid function to create the arrays."
In this case, you have four values in your X and Y matrices that correspond to the same point (0,0), which is invalid input for streamline. The specific problem is that the first column of y is all the same. Those coordinates are being passed into interp1 and that is what is generating the error message.
X and Y are meant to reflect the coordinates of a grid of points, but the coordinates you provided are not really in a grid. Can you give more detail about what the values of X and Y mean in your data?
1 comentario
Leonardo Molino
el 7 de Mzo. de 2023
Editada: Leonardo Molino
el 7 de Mzo. de 2023
David Wootton
el 13 de Feb. de 2024
Is there more on how to ovecome this error?
I'm having the same problem; I would like to show streamlines for ideal flow around a cylinder, so I'm also using a domain build from radial coordinates (using transfinite interpolation). I have tried just plotting the upper half-plane since it's symmetric, and there is no danger that the points are not unique.
If I plot contours of the streamfunction it works fine, but I would prefer to have arrows showing the flow direction, and to plot the streamlines over a different field (velocity magnitude or pressure coefficient) so would prefer to use streamslice or streamline, both of which crash out.
0 comentarios
Ver también
Categorías
Más información sobre Vector Fields 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!