transform vector in 2 dimensions into one in 3

1 次查看(过去 30 天)
for i = 1:duration
traci.simulation.step();
for n = 1: length(inductionID)
veicoliOGNIISTANTEsuInduction(n,i)=traci.inductionloop.getLastStepVehicleNumber(inductionID{n});
end
for v=1:length(k)
if i==t(v)
for n = 1: length(inductionID)
veicoliT(n,v)=sum(veicoliOGNIISTANTEsuInduction(n,(t(v)-(T-1)):t(v)));
end
newgreentime(:,v)=L*veicoliT(:,v); % L is a constant matrix
end
end
hi all, i have a vector n rows by v (whose columns are indexed). my vector newgreentime (:, v) in the considered v becomes a vector 4 x1, I would like to use this vector in a 3 dimensional vector 2x2xv how can I do it?

采纳的回答

Walter Roberson
Walter Roberson 2022-3-1
newgreentime(:,:,v) = reshape(L*veicoliT(:,v), 2, 2); % L is a constant matrix
This assumes that you want the order
A B C D ->
[A C
B D]
if you need
[A B
C D]
then
newgreentime(:,:,v) = reshape(L*veicoliT(:,v), 2, 2).'; % L is a constant matrix
  4 个评论
Marco Carapellese
thank you so much. Because i have see that it works also with " ' " as well as " .' "
Voss
Voss 2022-3-2
" .' " (dot single-quote) is transpose.
" ' " (single-quote) is complex conjugate transpose.
If the thing you are transposing (say X) contains only real values (i.e., no complex numbers), then X.' is the same as X'

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by