Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Simple Array Addition

Simple Array Addition

Simple Array Addition

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?



RE: Simple Array Addition

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.  

RE: Simple Array Addition


Thank you. I knew it was something simple.


RE: Simple Array Addition

there's a few ways of doing it, the obvious one being

SubgradeWidth[n: 2+RoadWidth[n


Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Simple Array Addition

Matrix + Constant
Simply typr


(to get it right assume you are wrong)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close