Streamline xy(20x1) & velocity component(400x1)
2 views (last 30 days)
Show older comments
Hi I have input the following codes and the same error message seem to keep appearing, which say
'??? Error using ==> stream2 at 47, U,V must all be size 2x2 or greater.'
the following are my codes, please advice where did I make a mistakes? Thanks.
x=xyRp(:,1);
y=xyRp(:,2);
u=VelRp(:,1);
v=VelRp(:,2);
[sx, sy] = meshgrid(linspace(min(x),max(x),400), linspace(min(y),max(y),400));
[x y] = linspace((min(x), max(x), 400), (min(y), max(y), 400))
hhh = stream2(x, y, u, v, sx, sy);
Answers (2)
Walter Roberson
on 29 Oct 2012
You say your velocity component is 400x1, but you index it as (:,1) and (:,2) which implies that either it is something-by-2 (at least) or else that it is 1 x 400 instead of 400 x 1. If it is 1 x 400 then u and v would come out as single elements. If it is something-by-2 then u and v would come out as column vectors and column vectors are not at least 2 wide to meet the 2 x 2 requirement.
Sean de Wolski
on 29 Oct 2012
The error is occuring because x and y are vectors and thus their size is not greate > [2 2]
I don't understand what you're doing with linspace either? Calling it with two output arguments should throw an error.
2 Comments
Sean de Wolski
on 29 Oct 2012
You need to use meshgrid to generate every pair of xy points:
[xx yy] = meshgrid(xy(:,1),xy(:,2));
Then you need to reshape the u/v vectors to be 20x20 which is the size xx and yy will be. With out knowing how those vectors (u/v) are ordered (and working on the big assumption that this is where the 400 values come from, i.e. each pair of u/v corresponds to one xx/yy pair), it is not possible for me to tell you the correct way to go about reshaping. Perhaps you could shed some light on that. I.e.
is u/v ordered:
x(1)y(1)
x(1)y(2)
or
x(1)y(1)
x(2)y(1)
Or some compltely other way?
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!