Create and combine quiver and contour plots

Im trying to figure out how to create and combine a quiver plot and a contourf using 4 vectors. I already have the quiver plot done but im stuck on the contourf. What i keep getting with the countourf is:
Error using contourf (line 61)
Z must be at least a 2x2 matrix.
Error in Importingshit (line 9)
contourf(x,y,vx,vy);
For the time being im just trying to get the contourf to work but if someone is willing to help me combine them then i would deffinitly not refuse. Thanks in advance!

Réponses (2)

Star Strider
Star Strider le 19 Déc 2014

0 votes

You’re calling contourf wrong. It doesn’t use the ‘vx’ and ‘vy’ (that I assume you use in your quiver plot). It wants a single square matrix ‘z’, or ‘x’, ‘y’, ‘z’ matrix arguments. See the documentation for it for details.

4 commentaires

Paul
Paul le 19 Déc 2014
you are correct that i am using the vx and vy in my quiver but the question is, i have 6 vectors i am using but for these i only need 4 (x,y,vx,vy) but when i write contourf(x,y) it brings me an error also and when it did work it was wrong. How do i incorporate vx and vy into contour (or something similar) and then "overlay" it onto the quiver?
Star Strider
Star Strider le 19 Déc 2014
...‘but when i write contourf(x,y) it brings me an error also and when it did work it was wrong’...
  1. What was the error it threw,
  2. What was ‘wrong’ when it worked?
1.
Error using contourf (line 61)
Z must be at least a 2x2 matrix.
2. when it "worked" it was making a countour but the contours didnt match up with the quiver. They werent representing what they should have so i did something wrong.
Star Strider
Star Strider le 19 Déc 2014
What are the sizes of x and y?
What is the surface you want to plot? It has to be a matrix, and ideally a function of matrices X and Y. The surface Z must be some function of X and Y if you give it all three arguments.
We don’t have your data or code, so we’re purely guessing here.

Connectez-vous pour commenter.

Thorsten
Thorsten le 19 Déc 2014
Modifié(e) : Thorsten le 19 Déc 2014
contourf(x,y,sqrt(vx.^2 + vy.^2));

1 commentaire

same error as above:
Error using contourf (line 61)
Z must be at least a 2x2 matrix.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Vector Fields dans Centre d'aide et File Exchange

Question posée :

le 19 Déc 2014

Commenté :

le 19 Déc 2014

Community Treasure Hunt

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

Start Hunting!

Translated by