# Need some help finding finding the gradient and creating a vector space to use contour and quiver plots.

2 visualizaciones (últimos 30 días)
Hunter Manning el 19 de Oct. de 2022
Respondida: Nithin Kumar el 8 de Sept. de 2023
The potential of an electric field due to a point charge is given (in spherical coordinates) by V= k/r where k is a constant. Assuming k = 1, find V in cartesian coordinates. Use Matlab to determine the gradient in cartesian coordinates via the symbolic toolbox , and then create a vector space and use the contour and quiver plots to illustrate the gradient of the function in the z = 0 plane.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Nithin Kumar el 8 de Sept. de 2023
Hi Hunter,
I understand that you want to determine the gradient in cartesian coordinates using Symbolic toolbox. To perform this analysis in MATLAB, kindly refer to the following steps:
1. Define the symbolic variables and constants:
syms x y z r k;
k = 1; % Assuming k = 1
r = sqrt(x^2 + y^2 + z^2); % Define r in Cartesian coordinates
2. Calculate the electric potential 'V':
V = k / r;
3. Calculate the gradient of 'V' in Cartesian coordinates:
4. Create a vector space in the xy-plane (z = 0) and evaluate the gradient:
[x_vals, y_vals] = meshgrid(-5:0.5:5, -5:0.5:5);
z_val = 0;
5. Create "contour" and "quiver" plots to illustrate the gradient in the "z = 0" plane:
figure;
% Contour plot of the electric potential
subplot(1, 2, 1);
contour(x_vals, y_vals, double(subs(V, [x, y, z], [x_vals, y_vals, z_val])));
title('Contour Plot of Electric Potential (V)');
% Quiver plot of the gradient
subplot(1, 2, 2);
title('Quiver Plot of Gradient of V');
xlabel('x');
ylabel('y');
% Adjust plot parameters as required
axis equal;
For more information regarding “meshgrid”, “sbs”, "contour" and "quiver" functions, kindly refer to the following documentation:
I hope this provides you with the required information regarding your query.
Regards,
Nithin Kumar.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Vector Fields en Help Center y File Exchange.

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by