フィルターのクリア

Issue with matrix combination - error with sin and cos in matrix

1 回表示 (過去 30 日間)
Tea Arrigoni
Tea Arrigoni 2017 年 12 月 14 日
コメント済み: Walter Roberson 2017 年 12 月 14 日
Hi,
I have a following situation and I am not sure how to solve it.
FiA=-10:20:170
FiFm=-60:10:170
FiF=Fifm+FiA/3
COSF=Cos(FiF)
SINF=Sin(FiF)
I have a variable (angle) FiA that goes in deg from -10 until 170 with a step od 20.
Than I have variable FiF that is equal to variable Fifm+FiA/3 and the variable Fifm is also in deg from -60 until 170 with the step of 20.
And this part I manage to generate but the problem starts when I want to write down all possibilities of matrix that have the following variable. For example:
F=[1 0 0: 0 cofFiF - sinFif: 0 sinFif cosFif]
Then I get the error. When I write down the sinus and cosinus i can get all kind of combination but if I put them i matrix it gives me error.
Do you know maybe why?

採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 14 日
FiA = -10:20:170;
FiFm = -60:10:170;
[gFiA, gFiFm] = ndgrid(FiA, FiFm); %you want all combinations
gFiF = gFiFm + gFiA / 3;
COSF = cosd(gFiF); %cosd and sind because you are working in degrees!
SINF = sind(gFiF);
F = arrayfun( @(sinFif, cosFif) [1 0 0; 0 cosFif -sinFif; 0 sinFif cosFif], SINF, COSF, 'uniform', 0);
The result will be a 10 x 24 cell array, in which each entry will be the rotation matrix for one Fia paired with one FiFm.
  2 件のコメント
Tea Arrigoni
Tea Arrigoni 2017 年 12 月 14 日
I need to add another variable that if dependent on these two. FiRm=-60:20:90
FiR=FiRm+7FiA/9 - FiF/9 + 2FiA*FiF/810
Its Matrix looks like this
R=[cosFiR - sinFir 0; sinFir cosFir 0 ; 0 0 1]
I tried to enter another variable in ndgrid but then everything goes wrong. Can you help on this issue? Thank you in advance
Walter Roberson
Walter Roberson 2017 年 12 月 14 日
FiA = -10:20:170;
FiFm = -60:10:170;
FiRm=-60:20:90;
[gFiA, gFiFm, gFiRm] = ndgrid(FiA, FiFm, FiRm];
gFiR = gFiRm + gFiA * (7/9) - gFiF / 9 + FiA .* FiF .* (2/810);
gcosFiR = cosd(gFiR);
gsinFiR = sind(gFir);
F = arrayfun( @(sinFir, cosFir) [cosFir -sinFif 0; sinFir cosFir 0; 0 0 1], gsinFir, gcosFir, 'uniform', 0);
The resulting cell array is going to be 3D, giving all possible combinations of the values of the variables.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by