Problem with dimensions using meshgrid

Not sure why my code isn't working
>> [x,y]=meshgrid(-100:1:100, -100:1:100)
>> z = (-4.3461.*(10.^-7)).*[1/[1 + ((x.^2)./(30^2))].^1.5];
Error using /
Matrix dimensions must agree.

 Accepted Answer

You need to vectorise every multiplication, division, and exponentiation:
z = (-4.3461.*(10.^-7)).*[1./[1 + ((x.^2)./(30^2))].^1.5];
↑ VECTORISE HERE AS WELL

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!