If loop matrix creation

1 visualización (últimos 30 días)
Justin Manterrnacch
Justin Manterrnacch el 8 de Oct. de 2021
Editada: DGM el 8 de Oct. de 2021
theta=[0,45,90];
F=450;
for i=0:length(theta)
vector=F.*[cosd(theta),sind(theta),0];
end
Want the matricies for vector that is created to be seperate. When it currently runs, all values are in the same matrix.

Respuestas (1)

DGM
DGM el 8 de Oct. de 2021
Editada: DGM el 8 de Oct. de 2021
"Want the matricies for vector that is created to be seperate."
What exactly does that mean? I'm assuming "matrices" means "vector", but that's still ambiguous. You want the outputs to be separate, but how exactly?
theta = [0,45,90];
F = 450;
% one row for each theta
matrix = F.*[cosd(theta.') sind(theta.') [0; 0; 0]]
matrix = 3×3
450.0000 0 0 318.1981 318.1981 0 0 450.0000 0
% one row for each axis
matrix = F.*[cosd(theta); sind(theta); [0 0 0]]
matrix = 3×3
450.0000 318.1981 0 0 318.1981 450.0000 0 0 0
That gives the result as a matrix. You can index within the matrix to find the vectors you want. If you want three separate vector variables, then I have no idea why you were trying to vectorize it in the first place.
If none of this is what you want, you'll have to clarify your description of how you want the output to be arranged.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by