Graphing z=x^2+(xy) in Matlab: What am I Doing Wrong?

  • Context: MATLAB 
  • Thread starter Thread starter JoshHolloway
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The forum discussion centers on graphing the equation z = x² + (xy) in MATLAB. The user provided code using meshgrid to create a 3D plot but encountered issues. A key syntactical error was identified: the user incorrectly included a period after Y in the multiplication (X. * Y.; instead of X.*Y). Correcting this syntax will resolve the issue and allow for proper graphing of the equation.

PREREQUISITES
  • Understanding of MATLAB syntax and operations
  • Familiarity with 3D plotting functions in MATLAB
  • Knowledge of meshgrid function in MATLAB
  • Basic algebraic manipulation of equations
NEXT STEPS
  • Review MATLAB documentation on the meshgrid function
  • Learn about MATLAB's 3D plotting functions, specifically mesh and surf
  • Explore error handling and debugging techniques in MATLAB
  • Study the implications of element-wise operations in MATLAB
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly those involved in mathematical modeling, data visualization, and anyone seeking to improve their coding accuracy in MATLAB.

JoshHolloway
Messages
221
Reaction score
0
I want to graph the equation [tex]z = x^{2} + (xy)[/tex] in matlab, but I can't figure out how to do it.

Here is the code I am trying:

EDU>> [X,Y] = meshgrid(-10:.5:10);
EDU>> Z = X.^2 + X. * Y.;
EDU>> mesh(X,Y,Z, 'EdgeColor', 'black')


What am I doing wrong?
 
Physics news on Phys.org
Anyone?
 
What makes you think you're doing something wrong?

I can see one syntactical mistake (X. * Y.; should be X.*Y;) but otherwise it looks ok
 

Similar threads

Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K