×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

(OP)
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

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

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.

(OP)
rd78-

Thank you. I knew it was something simple.

-KD

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

n:1;48

Cheers

Greg Locock

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

Matrix + Constant
Simply typr

Y

(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.

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!