|
"Michael Elite" <elitemichael@yahoo.com> wrote in message <ggsree$3is$1@fred.mathworks.com>...
> What I need to is to figure out how to find the lowest value for L when Tac and Tab are both <2000.
>
> I've tried directing them into an array, and trying to find the minimum of the array, but I can't seem to get the array to only take values where tac and tab are both <2000. It simply takes all the values and gives min(L) = 3.
>
>
> L=3:0.1:6.7;
> th = acos((45-L.^2)/36);
> ph = asin((6*sin(th))./L);
>
> j=1;
>
> Tab = 2000./(sin(th)+cos(th).*tan(ph));
> if Tab<2000 then
> Tac = (2000.*cos(th))./(sin(th)+cos(th).*tan(ph));
> if Tac<2000 then
> ARRAY(j)=(L,Tab,Tac)
> j=j+1;
> end
> end
>
> plot(L,Tab,'m',L,Tac,'b'),xlabel('Length of AC'),ylabel('Tension'),title('Tension Plot');
> legend('Tab','Tac');
>
> How do I put everything in a while loop where L starts as 3 and then increases by 0.1 until it get 6.7 ... HELP!!
It seems like you don't necessarily need to use a WHILE or FOR loop. With a conditional like this, I think it is easier to understand using conditionals.
L=3:0.1:6.7;
th = acos((45-L.^2)/36);
ph = asin((6*sin(th))./L);
Tab = 2000./(sin(th)+cos(th).*tan(ph));
Tac = (2000.*cos(th))./(sin(th)+cos(th).*tan(ph));
isTabConditional = ( Tab < 2000 );
isTacConditional = ( Tac < 2000 );
Array = L( isTabConditional & isTacConditional );
plot(L,Tab,'m',L,Tac,'b'),xlabel('Length of AC'),ylabel('Tension'),title('Tension Plot');
legend('Tab','Tac');
[mOfArray, mIdxOfArray] = min(Array);
fprintf(1, 'Min of Array is %d, Min index of Array is %d\n', ...
mOfArray, mIdxOfArray);
|