help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Running out of memory???


From: John W. Eaton
Subject: Running out of memory???
Date: Thu, 21 Jan 2010 12:28:28 -0500

On 21-Jan-2010, babelproofreader wrote:

| Can anyone explain why the script below is failing with error message
| 
| error: memory exhausted or requested size too large for range of Octave's
| index type -- trying to return to prompt
|  
| 
| the script :-
| 
| clear
| 
| r2_critical_values_5=load("-ascii","r2_critical_values_5");
| 
| period = input( "Enter period length for sinewave: " );
| sine_amp = input( "Enter sine amplitude: " );
| trend_inc = input( "Enter incremental trend change: " );
| 
| sinevector=zeros(500,1)';
| trendvector=zeros(500,1)';
| 
| for ii =2:500
|  sinevector(ii)=sinevector(ii-1)+(360/period);
|  trendvector(ii)=trendvector(ii-1)+trend_inc;
| endfor
| 
| original_sine=sine_amp*(sin(sinevector.*(pi/180)));
| trend_plus_sine=trendvector.+original_sine;
| 
| x = zeros(1:period)';
| ydep = zeros(1:period)';
| axis = (1:500)';
| slope = zeros(1:500)';
| r2 = zeros(1:500)';
| sig_slope = zeros(1:500)';
| 
| for i=period:500
| 
| ydep=trend_plus_sine(i-(period-1):i,1)
| [p,s]=polyfit(x,ydep,1);
| slope(i,1)=p(1);
| info=struct2cell(s);
| sse=(cell2mat(info(5)))^2;
| sst=sum((ydep.-mean(ydep)).*(ydep.-mean(ydep)));
| r2(i,1)=(sst-sse)/sst;
| if r2(i,1)>r2_critical_values_5(period)
| sig_slope(i,1)=1;
| endif
| 
| endfor
| 
| A=[axis,trend_plus_sine,slope,r2,sig_slope];
| dlmwrite("calcs_output",A)
| 
| I can't believe that any of the arrays created exceed 2 GB of memory, or
| that the memory on my computer is so limited that the script won't run - if
| I had such limited memory my computer would be grindingly slow, which it
| isn't?

It might be easier for someone else to help you debug your problem if
you provided all the information required to run the example code.
Where is the file r2_critical_values_5 and what values are supposed to
be entered for period, sine_amp, and trend_inc?  Also, how much memory
does your system have?

Have you tried stepping through the script, or inserting print
statements to trace its execution so that you can determine the point
at which the failure occurs?  Then you can find out precisely which
statement is causing the out of memory error, then go from there.
That would be my approach to debugging this type of problem.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]