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

  • SEARCH
  • Home
  • 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 7488591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:59:45+00:00 2026-05-29T14:59:45+00:00

I have lat, lon, data for a month data, I am working them to

  • 0

I have lat, lon, data for a month data, I am working them to put on a regular uniform grid (2 deg) without interpolation (bining). I am getting an error : index exceed dimensions”

I have lat, lon, var are in column matrix, these are obtained from multiple files of 1 month (thousands of rows).Here I am getting an error with X(zind(k,1),zind(k,2))=mean(zind(ind)); where the index exceed dimensions. Thanks for the help,

where x=lat, y=lon, z=var

   % make grid for scattered lat, lon, var
    data=load('mydata.txt')
    x=data(:,1);
    y=data(:,2);
    z=data(:,3);
    %make a grid with 2 degree
    cellsize=2;
    minx=-90;
    maxx=90;
    miny=-180;
    maxy=180;
    xi=(minx:cellsize:maxx);
    yi=(miny:cellsize:maxy);
    [X,Y]=meshgrid(xi,yi);
    [m,n]=size(X);
    %populate grid and make average
    xind=floor((x-minx)./cellsize)+1;
    yind=floor((y-miny)./cellsize)+1;
    zind=unique([yind,xind],'rows');
    Z=ones(m,n).*NaN;

    for k=1:length(zind)
    ind=find(xind==zind(k,2)&...
     yind==zind(k,1)==1);
  X(zind(k,1),zind(k,2))=mean(zind(ind));
 end
    %make a plot
    figure;
    axis([-180 180 90 -90]);
    imagesc(xi,yi,Z);
    **********************
  • 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-05-29T14:59:47+00:00Added an answer on May 29, 2026 at 2:59 pm

    First:

    ind=find(xind==zind(k,2)&...
         yind==zind(k,1)==1);
    

    I don’t think the ==1 should be there.

    Second, I think your error comes from the mean(zind(ind)): You don’t want the mean of zind, being indices of unique (y,x) indices. You want the mean of z:

    X(zind(k,1),zind(k,2))=mean(z(ind));  % changed last zind -> z
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a method to retrieve some data (lat,lon points) and open a
I have the following code but the lon/lat seems to be returning null; package
I have 3 points ( lat , lon ) that form a triangle.How can
i have a function to calculate several different values: int ASPfile::get_dimensions(int* Lat, int* Lon,
I have a data set with over 50,000 geocoded points (lat-long). Each point has
I have to work with strings which may contain Lat/Long data, like this: $query
I have an application which reads in gridded coordinate data with values (i.e. lat,
i have this demo xml file: <trains> <israel> <Lehavim> <lat>31.370201</lat> <lon>34.798336</lon> </Lehavim> <tel-aviv> <lat>32.073847</lat>
I have a dataframe such as: lat lon var01 var02 var03 var04 var11 var12
I have the Lat/Long value of New York City, NY; 40.7560540,-73.9869510 and a flat

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.