Out of memory error on interpolation
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
I am new in matlab. Recently i started some work. But i am stack at a point. I have a data of size = 301   241    46   119. Here some data is missing. But i need to fill all of this data. I tried to use interp3 for this. But i am getting out of memory exception. I also tried in https://matlab.mathworks.com/ Still same error, I need help to solve this problem  Here is my code  
% Check for missing values
missing_indices = find(isnan(temp_data));
% Identify the coordinates (latitude, longitude, depth, and season) of missing values
[lat_missing, lon_missing, depth_missing, season_missing] = ind2sub(size(temp_data), missing_indices);
% Perform data interpolation for missing values using interp3
temperature_interpolated = interp3(lon, lat, depth, season, temp_data, lon_missing, lat_missing, depth_missing, season_missing, 'linear');
% Replace missing values with the interpolated values
temp_data(missing_indices) = temperature_interpolated;
Error: 
Out of memory.
Error in internal.matlab.imagesci.nc/read (line 711)
                        data(data==fillValue) = NaN;
Error in ncread (line 76)
vardata = ncObj.read(varName, varargin{:});
1 Kommentar
  Torsten
      
      
 am 11 Jun. 2023
				Where in the examples did you find such a call to "interp3" ?
I only see calls with at most 7 inputs arrays.
Antworten (1)
  Walter Roberson
      
      
 am 11 Jun. 2023
        You are not running out of memory in a call to interp3(): you are running out of memory in a call to ncread()
The data file that you are reading is occupies more than 1/2 of your available memory, so when MATLAB tries to compare each data location to the fill value in order to convert fill values to nan, the temporary logical array that is generated fills the rest of remaining memory.
You might possibly be able to do better by using netcdf.open and netcdf.getVar yourself but you might have to disable fill using netcdf.setFill 
But you will probably find that in practice what you should be doing is using the ncread start and count parameters so that you are only reading in part of the variable at one time. For example it is often that case that you really only need the data for one timestep at a time -- that even if you are doing an animated plot, the processing on the data often effectively "summarizes" the data down to an array the size of your figure at a time, which can be much more managable. 
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Dates and Time finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


