×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

Calculating using individual array entries

Calculating using individual array entries

Calculating using individual array entries

(OP)
Hi,

   Im a beginner at matlab so please bear with me. I want to create a function that has 2 inputs from a datafile. Both are individual columns of a three column data file with input 1 as column 1 and input 2 as column 2. Is there a way I can make a formula to find the differences between consecutive entries in column 1? For instance, column 1 is:
5
8
2
7, therefore the output would be 3,-6,5. Any ideas? Thanks for any help.

RE: Calculating using individual array entries

Wouldn't it be the same as what you would do mathematically, e.g., MD[i]=M[i+1]-M[i]?  where i ranges from imin to imax-1

TTFN



RE: Calculating using individual array entries

JohnKGH,

Boy you really are new to Matlab!  Operations on columns of data are the bread and butter of Matlab analyses:


>> x=[5 8 2 7]'

x =

     5
     8
     2
     7

>> diff(x)

ans =

     3
    -6
     5

RE: Calculating using individual array entries

(OP)
Wow...I feel stupid. Thanks for the tremendous help you guys!. BTW, is there a good website to reference for programming help?

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!


Resources