maximum variable size allowed by the program is exceeded?
5 views (last 30 days)
Show older comments
advaita vedanta
on 1 Sep 2014
Answered: advaita vedanta
on 2 Sep 2014
PLz help me
This is the code
alps=17; %slope angle
dz=200; %depth of water table from the suface
dlz=400; % toltal depth of slope
fi=25; %friction angle
C=0.4; %4 kpa=0.4 N/cm^2
gsat=0.21; %21 kN/m^3
gw=0.098; %9.81 Kn/m^3
Dzero=4; %0.0004m^2/s
ksat=1e-3; %e-5 m/s
iz=2e-4; %iz=7.2 mm/h= 2e-4 cm/s
deltat=10; %time step
deltaz=0.8; %space step
T=12*60*60; %time duration of rainfall= 12h to seconds
e=(deltat/deltaz^2)*Dzero*cos(17*pi/180)*cos(17*pi/180);
n=500; %time step, based on T
%Setup sparse matrix
b= sparse(1:n,1:n,-116.314,n,n); % element b... 1...n
c= sparse(1:n-1,2:n,e,n,n); % element c...
a= sparse(2:n,1:n-1,-e,n,n); % element a... 2...n-1
c(1)=114.314; a(1)=0; a(n)=114.314; %Boundary condition
A= a+b+c;
l=e*ones(1:n); m=112.314*ones(1:n); u=e*ones(1:n);
and This is the error below, please tell me why this error appears and how to solve. My system is 64 bit and 6gb ram and processor speed is 2.5 Ghz Error using ones Maximum variable size allowed by the program is exceeded.
Error in hillslopesparse (line 30)
l=e*ones(1:n); m=112.314*ones(1:n); u=e*ones(1:n);
0 Comments
Accepted Answer
per isakson
on 1 Sep 2014
Edited: per isakson
on 1 Sep 2014
ones(1:n) tries to create a n-dimensional monster. Try
>> ones(1:3)
ans(:,:,1) =
1 1
ans(:,:,2) =
1 1
ans(:,:,3) =
1 1
I assume that you want to create a vector. Try
m = ones(1,n);
k = ones(n,1);
whos m k
which returns
Name Size Bytes Class Attributes
k 500x1 4000 double
m 1x500 4000 double
More Answers (2)
Guillaume
on 1 Sep 2014
If you meant to create a matrix of ones of size n*n then the proper syntax is:
ones(n); %or ones(n, n);
As it is you're attempting to create a 500-d matrix with 1st dimension of size 1, 2nd dimension of size 2, ..., 500th dimension of size 500!
2 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!