필터 지우기
필터 지우기

Combining matrices without for loops

조회 수: 2 (최근 30일)
Joel Schelander
Joel Schelander 2021년 4월 12일
댓글: Walter Roberson 2021년 4월 15일
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?

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by