How to Correctly Implement Nested Loops for Surface Plotting in MATLAB?

Click For Summary
SUMMARY

The discussion focuses on implementing nested loops in MATLAB for creating surface plots. The user is attempting to vary two parameters while plotting a third variable as the dependent variable. The main issue highlighted is the incorrect assignment on the left-hand side of the statements, which results in a line in 3D space instead of the expected surface plot. The user seeks guidance on correcting the loop structure to achieve the desired output.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Familiarity with for loops and nested loops in MATLAB
  • Knowledge of surface plotting techniques in MATLAB
  • Basic grasp of variable assignment and scope in MATLAB
NEXT STEPS
  • Research MATLAB for loop syntax and best practices
  • Learn about creating surface plots in MATLAB using the surf function
  • Explore debugging techniques for MATLAB code to identify assignment issues
  • Study examples of nested loops in MATLAB for complex data visualization
USEFUL FOR

This discussion is beneficial for MATLAB programmers, data analysts, and anyone involved in scientific computing who needs to create complex visualizations using nested loops.

physicsCU
Messages
198
Reaction score
1
Hey guys,

Is there anyone good with MATLAB for loops? I am having trouble with getting an embedded loop within another loop to work.

I am trying to vary two parameters and create a surface plot with a third variable as the dependent.

What I really need help with is how to get the LHS of my statements correct. I will post my code later tonight, its on another computer, but if anyone has a good site to help me out in the mean time, that would be great.

Thanks!
 
Physics news on Phys.org
Er, what error are you getting?
 
Its not an error perse, its just that i get a line in 3d space, when i should be getting a surface plot, because two variables are being varied at all points.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
627
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K