# Homework Help: Plotting stress tensor in MATLAB, Parametric Surface

1. Feb 16, 2010

### Xaspire88

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.
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

Last edited by a moderator: May 4, 2017