Simple operations with vectors
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Igor Braz Gonzaga
el 13 de Mzo. de 2022
Comentada: Igor Braz Gonzaga
el 13 de Mzo. de 2022
Hi everyone. I am begining with Matlab and I have a doubt:
Follows my code:
t=0:1/(100*fe):Tmax;
Nped=10
for i=1:Nped
for 1:lenght(t)
dist(i)=vp(i)*t;
end
end
The error that appears is: Unable to perform assignment because the indices on the left side are not compatible with the size of the right
side.
Does anyone knows how can I fix it? Thanks a lot.
1 comentario
Respuesta aceptada
Torsten
el 13 de Mzo. de 2022
Editada: Torsten
el 13 de Mzo. de 2022
dist(i) is one single number (a scalar), vp(i)*t is a vector of the same length as t.
You can't assign a vector to a scalar element.
Do you mean
t = 0:1/(100*fe):Tmax;
Nped = 10;
for i = 1:Nped
for j = 1:lenght(t)
dist(i,j)=vp(i)*t(j);
end
end
or simply
t = 0:1/(100*fe):Tmax;
Nped = 10;
for i = 1:Nped
dist(i,:) = vp(i)*t
end
or even simpler
t = 0:1/(100*fe):Tmax;
dist = v.*t
if v is a column vector ?
?
Or maybe
t = 0:1/(100*fe):Tmax;
Nped = 10
for i = 1:Nped
dist{i} = vp(i)*t;
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!