Borrar filtros
Borrar filtros

transform vector in 2 dimensions into one in 3

1 visualización (últimos 30 días)
Marco Carapellese
Marco Carapellese el 1 de Mzo. de 2022
Comentada: Voss el 2 de Mzo. de 2022
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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Mzo. de 2022
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 comentarios
Marco Carapellese
Marco Carapellese el 2 de Mzo. de 2022
thank you so much. Because i have see that it works also with " ' " as well as " .' "
Voss
Voss el 2 de Mzo. de 2022
" .' " (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'

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Point Cloud Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by