필터 지우기
필터 지우기

Implement the following matrix

조회 수: 1 (최근 30일)
Tipu Sultan
Tipu Sultan 2019년 5월 15일
댓글: Tipu Sultan 2019년 5월 15일
I want implement a matrix which as follows:
212.25.png
where i is a subscript in my it will be a for loop which execute i=1:3 and theta,r,a,b,p,q,t arrays. theta,r,t are 1*3 matrix.a,b,p,q are 1*1 matrix.
The following is my approach:
theta = [ 45 46 48] ;
t= [ 1 2 3 ];
r= [200 210 220];
for i=1:3
dif_x = [(-cos(theta(i))) (r(i).*sin(theta(i))) (2*a.*t(i)+b);...
(-sin(theta(i))) (-r(i).*cos(theta(i))) (2*p.*t(i)+q)]
end
I want to know am I donig correct or not! and if I am wrong what will be the coorect approach.
Thanks in advance.

채택된 답변

Jan
Jan 2019년 5월 15일
The code overwrites dif_x in each iteration. Maybe you want to collect the different matrices instead:
theta = [ 45 46 48] ;
t = [ 1 2 3 ];
r = [200 210 220];
dif_x = zeros(2, 3, 3); % Pre-allocation
for i=1:3
dif_x(:, :, i) = [-cos(theta(i)), r(i).*sin(theta(i)), 2*a.*t(i)+b;...
-sin(theta(i)), -r(i).*cos(theta(i)), 2*p.*t(i)+q];
end
It is safer to separate the elements of arrays by commas.
  댓글 수: 1
Tipu Sultan
Tipu Sultan 2019년 5월 15일
Thank you for the prompt reply. Exactly I want to work with with each matrix for a particular iteration.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by