Error when plotting a 2-D vector field

2 次查看(过去 30 天)
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.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Octave 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by