Problem with drawing a function in MATLAB

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 4K views
Physics_rocks
Messages
12
Reaction score
0
hi guys ,

I'm trying to draw the following function , however MATLAB doesn't like my code . What am I doing wrong ?

z = x + (y – 100)^2

where x = -50 : 50,
y = 0 : 200


my code :

[x,y]=meshgrid(-50:1:50,-0:1:200)
surf(x , y , x. + (y.-100)^2)


thank you
 
Physics news on Phys.org
You have the dots in the wrong place
Code:
surf(x , y , x + (y-100).^2)