# MATLAB: Computational time nested if commands

computational timenested ifs

Hi there,
I am attaching an mfile with nested ifs – it is really simple and I include the commenting, so it is easily read.
However, it takes for ever to execute. The weird thing is that if I exclude only one condition (one nested if – the >1.11 Z see code) , it executes really fast. I really cannot spot weather there is a mistake in the code – it doens't return anth as an error, just simply never stops, so I was just hoping for you MATLAB guru's.
Thanx a lot in advance! Stella

#### Best Answer

• us1 = abs(Us(:,1:48));x = us1(:,[1:30,36:48]);z = us1(:,[31,32,34,35]);p = us1(:,33);l1 = all([bsxfun(@gt,p,2*x),2), bsxfun(@gt,p,1.11*z)],2);Usvalid = Us(l1,:);Usnonvalid = Us(~l1,:);