- #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
http://i666.photobucket.com/albums/vv22/Zzsark/Matlabproblem2.jpg
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.
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
http://i666.photobucket.com/albums/vv22/Zzsark/Matlabproblem2.jpg
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: