If loop matrix creation
6 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
DGM
on 8 Oct 2021
Edited: DGM
on 8 Oct 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]]
% one row for each axis
matrix = F.*[cosd(theta); sind(theta); [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.
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!