Error: The size of X must match the size of U or the number of columns of U.
Mostra commenti meno recenti
What's the problem with this code? when I run it the following Error occurs:
Error using quiver
The size of X must match the size of U or the number of columns of U.
syms x y;
f=input('enter function: ','s');
f = symfun(eval(f), [x y]);
u=-diff(f,x);
v=-diff(f,y);
[X,Y]=meshgrid(-10:.5:10);
quiver(X,Y,u,v);
2 Commenti
KSSV
il 14 Mag 2017
Dimensions of X,Y and u,v should be same.
geometry geometry
il 14 Mag 2017
Risposta accettata
Più risposte (1)
Star Strider
il 14 Mag 2017
Remember that ‘u’ and ‘v’ are also functions of (x,y), so use them as ‘u(x,y)’ and ‘v(x,y)’. With one change (changing the step in the meshgrid vector to 0.51 to prevent ‘division by zero’ errors), this works:
syms x y;
% f=input('enter function: ','s');
f = 'log(x^2+y^2)';
f = symfun(eval(f), [x y]);
u=-diff(f,x);
v=-diff(f,y);
[X,Y]=meshgrid(-10:.51:10);
quiver(X,Y,u(X,Y),v(X,Y),5);
Categorie
Scopri di più su Vector Fields in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
