[Scilab-users] Loop query - Scilab 5.5.2

Tim Wescott tim at wescottdesign.com
Mon Jan 18 21:51:21 CET 2016


Or you can build a three column array as a matrix.  Here's my example,
but I don't see where 'x' is defined.

Te = (5000:10000:25000)';
D = E * Te .^ 3 / (12 * (1 - v^2));
lambda = ((rho_m - rho_fill) * g ./ (4 * D)) .^ 0.25;
lambda_k = lambda * 1000;
flex = (2 * Pb * lamda / ((rho_m-rho_fill)*g)) .* ..
       exp(-lamda_k .* x) .* cos(lamda_k .* x);

On Mon, 2016-01-18 at 14:48 +0100, Serge Steer wrote:
> The plot instruction should be inside de loop
> 
> k=0;
> st=["r","g","b"];
> for Te = 5000:10000:25000 // start: step: end
>      k=k+1
>      D = E*Te .^3/(12*(1-v^2));
>      lamda = ((rho_m-rho_fill)*g ./(4*D)).^0.25;
>      lamda_k = lamda*1000;
>      flex = [flex,2*Pb*lamda/((rho_m-rho_fill)*g)*exp(-lamda_k*x).*cos(lamda_k*x)];
>      plot(x,flex,st(k))
>   end
> 
> 
> 
> or you may build a three column array . in the script below I assume x 
> is a column vector
> 
> flex=[];
> for Te = 5000:10000:25000 // start: step: end
>      D = E*Te .^3/(12*(1-v^2));
>      lamda = ((rho_m-rho_fill)*g ./(4*D)).^0.25;
>      lamda_k = lamda*1000;
>      flex = [flex,2*Pb*lamda/((rho_m-rho_fill)*g)*exp(-lamda_k*x).*cos(lamda_k*x)];
>   end
> plot(x,flex)
> 
> 
> Le 18/01/2016 11:50, Lester Anderson a écrit :
> > Thanks for that pointer.
> >
> > The plot works but only does Te=25 in this case
> >
> > for Te = 5000:10000:25000 // start: step: end
> >      D = E*Te .^3/(12*(1-v^2));
> >      lamda = ((rho_m-rho_fill)*g ./(4*D)).^0.25;
> >      lamda_k = lamda*1000;
> >      flex = 2*Pb*lamda/((rho_m-rho_fill)*g)*exp(-lamda_k*x).*cos(lamda_k*x);
> > end
> > plot(x,flex)
> >
> > Can't get it to loop and plot the other values
> >
> >
> > On 18 January 2016 at 10:38,  <sgougeon at free.fr> wrote:
> >> Hello,
> >>
> >>
> >>> for Te = 5000:25000:10000 // start:end:step to make 5000, 15000, 25000
> >> The syntax is start:step:end, not start:end:step
> >>
> >> https://help.scilab.org/docs/5.5.2/en_US/colon.html
> >>
> >> Samuel Gougeon
> >> _______________________________________________
> >> users mailing list
> >> users at lists.scilab.org
> >> http://lists.scilab.org/mailman/listinfo/users
> > _______________________________________________
> > users mailing list
> > users at lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> >
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
> 
> 

-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432





More information about the users mailing list