0

I have a vector field in excel file and I use xlsread to read them and quiver3(X,Y,a,U,V,b) (X and Y their coordinates in plane and U and V their velocity in 2 axises) to plot them.

Now I want to get the streamlines over my field and I use streamline(X,Y,U,V,sx(0:10),sy(0:10)) for it. but "it doesn't work" And this is the error:

Subscript indices must either be real positive integers or logicals.

p.s. most probably, the error is because of starting points in x and y, I guess...

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
Changoleon
  • 31
  • 4
  • "it doesnt work". What does that mean? you got an error? shows something different? Throw us a bone here, we cant solve a problem with a line and a half of explanation. Post some minimal working example with what you get and what you want. – Ander Biguri Oct 22 '14 at 09:14
  • Yes it doesn't work!! Look, I have a vector field in excel file. I use xlsread to read them and quiver3(X,Y,a,U,V,b) (X and Y their coordinates in plane and U and V their velocity in 2 axises) to plot them. So far so cool, right? Now I want to get the streamlines over my field and I use streamline(X,Y,U,V,sx(0:10),sy(0:10)) for it. Yes It doesn't work. And this is the error: Subscript indices must either be real positive integers or logicals. thanks in advance buddy :) – Changoleon Oct 22 '14 at 09:23
  • OK, now we have more information we can work with. Please, edit your question with your new information. – Ander Biguri Oct 22 '14 at 09:26

1 Answers1

1

Your problem is basic understanding of Matlab.

In Matlab matrix indexes start from position 1, not 0 as in C\C++ and well, almost any other language.

so for a given matrix A=[8 2 4 3 6 7 2], A(1)=8, A(3)=4, A(1:4)=[8 2 4 3]. However A(0) doesn't exist! You are triying to do a streamline using data from sx(0:10), sy(0:10), but as Matlab clearly tells yo: Subscript index must either be REAL POSITIVE INTEGERS or logicals.

And clearly, 0 is not a real positive integer.

Read more about indexin in matlab here: http://www.mathworks.co.uk/company/newsletters/articles/matrix-indexing-in-matlab.html

Hope it helps.

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
  • thank you for information. You are right. In sx (0:10) instead of 0 I put 1 or any REAL POSITIVE integer and now the error is: Undefined function 'sx' for input arguments of type 'double'. I found a similar example on mathworks but I just can't understand the system of numbers. It's here: [sx,sy,sz] = meshgrid(80,20:10:50,0:5:15); you can find the example here: http://www.mathworks.com/help/matlab/visualize/visualizing-vector-volume-data.html#f5-7374 For example what does 80 or 20 stands for in this example? @anderbiguri – Changoleon Oct 22 '14 at 10:09
  • @itsddadgar A good aproach is to search the function in the help because it is explained there: http://www.mathworks.co.uk/help/matlab/ref/meshgrid.html. The error you have now is because you havent run the piece of code you showed me. The error is because the variable doesnt exist yet. I hihgly recomend you to do some matlab tutorials before ansking in stackoverflow, to ensure you have some basic understanding a priori. Hope it helps – Ander Biguri Oct 22 '14 at 11:12
  • @itsddadgar Additionally, reading the links you provide is a good exersice usually. If you read the link you just posted: "This statement defines the starting points as all lying on x = 80, y ranging from 20 to 50, and z ranging from 0 to 15. " – Ander Biguri Oct 22 '14 at 11:15
  • I appreciate your help and information, but I don't think this webpage is only for professionals. It has a section where it says ask a question which means if you don't know something, ask it here. Thank you again for the time you spent. – Changoleon Oct 22 '14 at 13:59
  • @itsddadgar Definetly! and here we are to help! but it also says that you need to do basic research by yourself. At least you need to show that you googled it. Tens of questions are closed every day just because the OP did,t do basic research. Read: http://stackoverflow.com/help/how-to-ask – Ander Biguri Oct 22 '14 at 14:03