Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8611115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:17:30+00:00 2026-06-12T04:17:30+00:00

I have some large matrices of data, and a a two column matrix containing

  • 0

I have some large matrices of data, and a a two column matrix containing x and y locations, is there an easier way to work with the data elements corresponding to those points then:

for adj = 1:size(loc,1)
    testFunc(data1(loc(i,2),loc(i,1)), data2(loc(i,2),loc(i,1)), othervals)
end

Mostly I’m looking for a way to access the data elements by something closer to data1(loc(i))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:17:31+00:00Added an answer on June 12, 2026 at 4:17 am

    What you want is to access elements of data via their linear indices. Linear indices increment first along the first dimension, then along the second dimension, and so on. For example the elements of a 3-by-2 array would be addressed in the following order

    1 3 5
    2 4 6
    

    So to get element (2,1) of a 2-by-3 array via linear indexing, you would call array(3). To convert between linear index and subscripts (such as the pair 2,3), you can use ind2sub and sub2ind, respectively.

    In your case, you’d run

    linIdx = sub2ind(size(data),loc(:,2),loc(:,1))
    

    if the first column of loc indexes into columns of data, and the second column of loc indexes into rows.

    Then you can loop over linIdx to change your function call inside the loop to

    testFunc(data1(linIdx(i)), data2(linIdx(i)), othervals)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some large arrays of 2D data elements. A and B aren't equally
I have some large chunk of data that I want to send to the
I have a large data.frame displaying some weird properties when plotted. I'd like to
I have two large source trees. One of them has some out of date
I have some large tables (millions of rows). I constantly receive files containing new
I have some large data sets (numeric and textual) and as I'm studying and
I have some large vectors, the data of them are coming from some calculations
I currently have some large strings that I would like use as test data
We have some very large data files (5 gig to 1TB) where we need
I have some large data files and I want to copy out certain pieces

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.