MATLAB not able to make calculation - array limit
Ältere Kommentare anzeigen
I want to find the new max electricity consumption of an appartment when an EV is introduced.
Appartment is the load profile for 16 appartments (one value each minute for one year)
A is the load profile from charging for 2 vehicles.
I use this
nHousehold =size(Appartment, 2);
Appartment=525600*16 double
A=525600*2 double
for x = 1:nHousehold
App = Appartment(:, x);
for y = 1:nA
Vehicle = A(:, y);
I(x,y) = max(Vehicle.'+App)./max(App);
end
end
I get this error:
Requested 525600x525600 (2058.3GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become
unresponsive. See array size limit or preference panel for more information.
Error in RELATION (line 41)
I(x,y) = max(Vehicle.'+App)./max(App);
The output I should be a 16*2 matrix, so I wonder if I somehow can circumvent this error?
7 Kommentare
I don't know how you're getting an error, since this code isn't going to run at all.
You're referencing a variable before it's defined.
nHousehold =size(Appartment, 2);
These lines are going to throw an error. I'm going to assume that this is pseudocode for the sake of this example. Maybe this is defined before the prior line?
Appartment=525600*16 double
A=525600*2 double
The inner loop iteration vector references a variable that doesn't exist:
for y = 1:nA
I don't know why you're taking the elementwise transpose of a column vector and then trying to add it to another column vector. That's not going to work.
I(x,y) = max(Vehicle.'+App)./max(App);
I'm just guessing, but is this what you're trying to do?
Household=rand([525600 16]);
EVprofile=rand([525600 2]);
nH=size(Household, 2);
nEV=size(EVprofile, 2);
I=zeros([16 2]);
for x = 1:nH
thishousehold = Household(:, x);
for y = 1:nEV
thisevp = EVprofile(:, y);
I(x,y) = max(thisevp+thishousehold)./max(thishousehold);
end
end
Joel Schelander
am 22 Mär. 2021
@DGM: "I don't know why you're taking the elementwise transpose of a column vector and then trying to add it to another column vector. That's not going to work."
This is working since Matlab R2016b and called "auto-expanding" (or similar names):
(1:3).' + (4:5)
ans =
5 6
6 7
7 8
This was done by bsxfun in former Matlab versions.
The only problem is, that the vectors are to large to fit into the memory. But even with using a loop this would be very slow, because it would compare 276e6 values in each loop.
@Joel Schelander: Are Appartment and A filled with non-zero values? Would rand(525600, 16) be a real world data set? Or do the data have a specific structure?
Do you want to find the maxium of the sum of the two vectors? Or dou you want to find out, which combination of all elements of the vectors are maximal?
Having a tiny input data set and the wanted output would clarify this immediately.
DGM
am 22 Mär. 2021
Oh. I didn't know that. I'm on R2015b.
Joel Schelander
am 22 Mär. 2021
DGM
am 22 Mär. 2021
Yeah, that rand() was me just adding a dummy variable into the example when I was testing it
Joel Schelander
am 22 Mär. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!