Plotting stress tensor in MATLAB, Parametric Surface

In summary, to plot a 3D parametric surface of normal stress in spherical coordinates in MATLAB, use the surf() command with the appropriate values of theta and phi.
  • #1
Xaspire88
100
0
First off, I'm not sure if MATLAB questions go here or not, or if they are even dealt with on this forum. If not more or remove I guess.

I am no MATLAB wiz so this is mind-boggling to me. I am given a state of stress at a critical point of a component and told to plot a 3D parametric surface of the normal stress, but in spherical coordinates.*see attached figure*

http://i666.photobucket.com/albums/vv22/Zzsark/Matlabproblem.jpg [Broken]
http://i666.photobucket.com/albums/vv22/Zzsark/Matlabproblem2.jpg [Broken]

I tried plotting the equation given for sigma_nn for the indicated values of theta(0:2pi) and phi(0:pi), and it output a surface but I was expecting to get a spherical shape, and this was no where near spherical.

Some of my MATLAB code:

>> sigma=[200 100 120;100 350 100;120 100 300];
>> theta=sym('theta');
>> phi=sym('phi');
>> n=[cos(theta)*sin(phi);sin(theta)*sin(phi);cos(phi)];
>> sigma_normal=sigma*n*n';
>> theta=0:0.2:2*pi;
>> phi=0:0.1:pi;
>> Z=eval(sigma_normal);
>> Z=abs(Z);
>> surf(Z)

any direction or advice as how to correctly plot a parametric surface in MATLAB such as this would be much appreciated.
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
To plot a parametric surface in MATLAB, you will need to use the surf() command. The syntax for this command is as follows: surf(X,Y,Z). X and Y represent the values of theta and phi, respectively, while Z represents the normal stress value. For example, if you wanted to plot the surface for theta = 0 to 2pi and phi = 0 to pi, you could use the following code: theta = 0:0.2:2*pi;phi = 0:0.1:pi;[X,Y] = meshgrid(theta,phi);Z = eval(sigma_normal);surf(X,Y,Z);
 

1. What is a stress tensor in MATLAB?

A stress tensor in MATLAB is a mathematical representation of the stress experienced by a material at a specific point. It is a 3x3 matrix that contains nine components representing normal and shear stresses in three dimensions.

2. How can I plot a stress tensor in MATLAB?

To plot a stress tensor in MATLAB, you can use the surf or surf2xyz functions. These functions take in the stress tensor components as inputs and generate a 3D surface plot of the stress distribution.

3. Can I customize the appearance of the stress tensor plot?

Yes, you can customize the appearance of the stress tensor plot by using various MATLAB functions such as colormap, colorbar, and view. These functions allow you to change the color scheme, add a color bar legend, and change the viewing angle of the plot.

4. What is a parametric surface in MATLAB?

A parametric surface in MATLAB is a surface defined by a set of parametric equations. It is a two-dimensional surface embedded in three-dimensional space and can be represented using a grid of points or a mathematical function.

5. How can I plot a parametric surface in MATLAB?

To plot a parametric surface in MATLAB, you can use the surf function with the parametric equations as inputs. Alternatively, you can use the fsurf function, which is specifically designed for plotting parametric surfaces.

Similar threads

  • Topology and Analysis
Replies
16
Views
469
Replies
2
Views
1K
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
488
  • Calculus and Beyond Homework Help
Replies
7
Views
881
Replies
3
Views
244
  • Advanced Physics Homework Help
Replies
1
Views
301
Replies
7
Views
710
Replies
3
Views
283
  • Differential Geometry
Replies
3
Views
2K
Back
Top