フィルターのクリア

deviation from the average value less

4 ビュー (過去 30 日間)
Marco Carapellese
Marco Carapellese 2022 年 3 月 12 日
コメント済み: Marco Carapellese 2022 年 3 月 12 日
hello everyone, I have a vector composed of 34 rows by 40 columns, I would like to calculate the average value of each row (therefore a 34x1) and then find the column of the starting vector that is closest to that column made up of average values, to then be able to find the corresponding column number . how can do it? thanks
my array name is veT:
for i = 1: duration
traci.simulation.step();
if i==1
for f=1:length(semafori)
traci.trafficlights.setPhaseDuration(semafori{f}, nominali(f,1))
end
end
for n=1:length(induction)
vec_sec(n,i)=traci.inductionloop.getLastStepVehicleNumber(induction{n});
end
for v=1:length(k)
if i==t(v)
for j=1:length(vec_sec(:,1))
veT(j,v)=sum(vec_sec(j,(t(v)-(T-1)):t(v))); % this is vector by34x40
end
for f=1:length(semafori)
traci.trafficlights.setPhase(semafori{f},0);
traci.trafficlights.setPhaseDuration(semafori{f},nominali(f));
end
end
end
end
traci.close

採用された回答

Torsten
Torsten 2022 年 3 月 12 日
[m,i] = min(vecnorm(veT-mean(veT,2)))
  5 件のコメント
Torsten
Torsten 2022 年 3 月 12 日
This is the minimum value itself, i.e. the minimum 2-norm of the difference between the columns and the average column.
Marco Carapellese
Marco Carapellese 2022 年 3 月 12 日
thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by