If loop matrix creation

6 ビュー (過去 30 日間)
Justin Manterrnacch
Justin Manterrnacch 2021 年 10 月 8 日
編集済み: DGM 2021 年 10 月 8 日
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.

回答 (1 件)

DGM
DGM 2021 年 10 月 8 日
編集済み: DGM 2021 年 10 月 8 日
"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.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by