tags:

views:

67

answers:

0

hi. i am new to scilab. can somebody please tell me how to convert this c++ code to scilab code? thanks!

#include <stdio.h>
#include <math.h>
int main (void)
{
    double c= 12.5;                 // kg/s
    double g = 9.8;                 // m/s
    double m = 68.1;                // kgs
    double vt[200];                 // velocity in m/s and time in secs
    double v[200];
    int t;


    printf("Analytical Method\n\n");

    for (t=0; t<=13; t=t+2)
    {
    vt[t] = ((g*m)/c)*(1 - exp((-c/m)*t));
    printf("The velocity is %.2f m/s at %.1d sec.\n", vt[t],t);
    }
    vt[t] = ((g*m)/c)*(1 - exp((-c/m)*200));
    printf("The velocity at infinity is equal to %.2f m/s\n\n\n", vt[t]);



    printf("Numerical Method\n\n");
    v[0]=0;
    for (t=0; t<=13; t=t+2)
    {
        v[t+2] = v[t] + ((g-(c*v[t]/m))*2);
        printf("The velocity is %.2f m/s at %.1d sec.\n", v[t],t);
    }

    for (t=0; t<=200; t=t+2)
    {
        v[t+2] = v[t] + ((g-(c*v[t]/m))*2);
    }
    printf("The velocity at infinity is equal to %.2f m/s\n", v[t]);
    getchar();
    return 0;
}