Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Array Addition

Status
Not open for further replies.

KatiLynSki

Civil/Environmental
May 16, 2005
33
0
0
US
I am having a very difficult time with a very simple problem.

I have an array, RoadWidth[n (where n= 1..48). I want to add a constant to each of the values in the array. In my head this can be accomplished with a simple for loop but I just can't get it to work.

for n = 1..48
SubgradeWidth[n = (RoadWidth[n) + 2

This is obviously the wrong way to do it. (I know I could just add an array of the same size that has a 2 in each variable spots but that just seems like it would take up a lot more room on my calc sheet and would take more effort to change the 2 to any other variable that I want at some later date.)

Any insight on this lovely Friday morning?

THANKS

-KD
 
Replies continue below

Recommended for you

I just tried defining road as a matrix (48x1). Then define subgrade= road+2. It works fine. The result is a matrix with individual values 2 greater than road. You maybe be having a problem using the range variable n.
 
Status
Not open for further replies.
Back
Top