jeudi 24 août 2017

Calling if else output to other script

I have written a function called "tension.m" in which I have used if else condition as shown below.

function [T,T_earlyvalues,T_latervalues] = tension(u,sigma,G,N,K)
%the values of sigma,G,N,K can be taken arbitrary.
sigma=2; G=3;N=8;K=1; v=1;
w=2.2;
if u<w
  T =v*sqrt(sigma+G^2/(N-K));
  T_earlyvalue=T;
else
  T=(2*v)*sqrt(sigma+G^2/(N+K));
  T_latervalue=T;
end

Now in another script "myvalues.m" I need to call T_earlyvalues and T_latervalues separately.

%have some coding before this part
sigma0=2400; lambda=1.3; v=2; sigma=2; G=3;N=8;K=1;  
u=0:0.01:5;  
T=tension(u,sigma,G,N,K);
T_earlyvalues=tension(u,sigma,G,N,K);
T_latervalues=tension(u,sigma,G,N,K);
deltaA=T_earlyvalues*sigma0*pi;
deltaB=T_latervalue*lambda*pi/2;
%have some coding after this part

How could I call the said values which are under if-else statement from tension.m function to myvalues.m script?

Aucun commentaire:

Enregistrer un commentaire