¿Could somebody optimize this short code to get worst principle stress from tensor?

Hello, I would really appreciate if some body could show me a fast way to get a worst principle stress from a matrix of stress tensors.
My current solution is not vectorized and it uses eig, I should say that this function is called by a parallel (parfor) loop. I dont know if I could make a second parallel loop here but I think it wont works, I am looking for a clever way. I tried solving the characteristic polynomial but it didnt work....
function [SP]=gS(ST,Sigma)
%INPUT : Stress tensor ST=(S11,S22,S33,S12,S13,S23) in Row Sigma 'VM' 'WPS'
switch Sigma
case 'WPS'
SP=zeros(size(ST,1),1);
for iST=1:size(ST,1)
STm=[ST(iST,1),ST(iST,4),ST(iST,5);...
ST(iST,4),ST(iST,2),ST(iST,6);...
ST(iST,5),ST(iST,6),ST(iST,3)];
[SPm]=eig(STm);
[~,I]=max(abs(SPm)); SP(iST)=SPm(I);
end
end
thanks!

Answers (0)

Categories

Asked:

on 9 Feb 2014

Edited:

on 9 Feb 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!