help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Short Cut Way to Assign the Variables x1, x2....x40 names


From: Ed Song
Subject: Short Cut Way to Assign the Variables x1, x2....x40 names
Date: Sat, 13 Sep 2014 11:43:49 -0700

Hello,

I have a 40 period model and want to assign the variable x1, x2...x40 names without having to write the same subroutine 40 times. I remember in Fortran and Pascal we use to assign the variable x an index i, hence xi. Then use a Do Loop to calculate x1 through x40 without having to write out the routine 40 times. I'm trying to make heads or tails out of the manual, but am having a difficult time. Is there a way I can make the calculation 40 times doing the routine once instead of 40 times?

For example, suppose x1 = y1 + a, and x2 = y2 + a...x40=y40+a

In Fortran we would write a program something like this:

Do i=1,40
     xi=yi+a

In the following program I didn't have to write out x2=y2+a, x3=y3+a...etc.

Is there a similar procedure in Gnu Octave? How would I write an equivalent program to the above in Gnu Octave?

Ed

reply via email to

[Prev in Thread] Current Thread [Next in Thread]