Combining matrices without for loops

1 visualización (últimos 30 días)
Joel Schelander
Joel Schelander el 12 de Abr. de 2021
Comentada: Walter Roberson el 15 de Abr. de 2021
I have two houses, House 1 and house 2. Each house has one or two Electric Vehicles(EV), each EV has its own specific ID number. I want to find how much more max power House 1 and House 2 are jointly demanding when EVs are introduced. So far I have used for loops like this:
Vehicle1{jj}, Vehicle2{jj2} and HH2 are of the size 525600x1 double: the power demand every minute of the year
In this example there are 3 available vehicles, so the Vehicle and VID cells will both have the size 3x3
%Vehicle1 - electricity consumption of House 1s vehicle(s)
%Vehicle2- electricity consumption of House 1s vehicle(s)
%VID1 - ID number of vehicle(s) for House 1
%VID2 - ID number of vehicle(s) for House 2.
%HH2
for jj=1:numel(VID1)
V11=Vehicle1{jj};
ID1=VID1{jj};
for jj2=1:numel(VID2)
V22=Vehicle2{jj2};
ID2=VID2{jj2};
%Removes all doubles (House 1 and House 2 cannot have the same car)
if numel(intersect(ID1,ID2))
continue
end
INCREASE2{jj,jj2}=max(HH2+V11+V22)./max(HH2);
%IDcell2{jj,jj2}=[ID1 ID2];
end
end
Since there are many vehicles to consider and more houses to combine, I need to find another way to perform this calculation.
Is there some other way?

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by