Error when plotting a 2-D vector field

2 views (last 30 days)
Melissa A.
Melissa A. on 21 Mar 2019
Edited: Melissa A. on 21 Mar 2019
Hello Mathworks Community,
I am trying to plot the electric field vector on matlab , but I am encountering problems. I would like to write the x and why components of the vector field described in the picture below.
When I try to write x component of the vector field i encounter the error mentioned below.
Thank you for your help
>> Nx=100; %number of mesh points on x-axis
>> Ny=100; %number of mesh points on y-axis
>> xrng = linspace (-100,100,Nx);
>> yrng= linspace(0,200,Ny); %specifying the ranges for the x and y axes
>> [X_grd, Y_grd] = meshgrid(xrng,yrng); %2-D grid
>> Eps=8.854*10^-12;
>> E_x=2*(X_grd-2)/k((X_grd-2).^2 +(Y_grd-2).^2).^3/2;
Array indices must be positive integers or logical values.

Answers (0)

Community Treasure Hunt

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

Start Hunting!