Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Subscripted assignment dimension mismatch when using coeffs command
조회 수: 1 (최근 30일)
이전 댓글 표시
dear all
i have code like below:
clc
clear all
syms q(i) teta(i) eb(i)
tetad = sym('tetad', [1 2], 'real');
ebd = sym('ebd', [1 2], 'real');
qd = sym('qd', [1 2], 'real');
i=2;
wl(:,:,i)=[-sin(q(i))*tetad(i)-cos(q(i))*sin(teta(i))*cos(teta(i))*qd(i)+cos(q(i))*sin(teta(i))*ebd(i);cos(q(i))*tetad(i)-sin(q(i))*sin(teta(i))*cos(teta(i))*qd(i)+sin(q(i))*sin(teta(i))*ebd(i);((sin(teta(i)))^2)*qd(i)+cos(teta(i))*ebd(i)];
Ecollected=collect(wl(:,:,2),[qd(2),tetad(2),ebd(2)])
for i=1:size(wl,1)
w(i,:)=coeffs(Ecollected(i),[qd(2),tetad(2),ebd(2)])
end
at end i get error Subscripted assignment dimension mismatch.
and answer should be like this :
[ cos(q(2))*sin(teta(2)), -sin(q(2)), -cos(q(2))*cos(teta(2))*sin(teta(2))] [ebd ]
[ sin(q(2))*sin(teta(2)), cos(q(2)), -cos(teta(2))*sin(q(2))*sin(teta(2))]*[tetad]
[cos(teta(2)) , 0, sin(teta(2))^2] [qd ]
i understand why i get this error and that is because of Ecollected(3) that have 2 value [cos(teta(2) sin(teta(2))^2] and it cant fit in 3 column and it should be like [cos(teta(2) 0 sin(teta(2))^2] and 2 other Ecollected(2) ,Ecollected(1) works fine
i really appreciated if someone can help me
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 12월 12일
[wtemp, vtemp] = coeffs(Ecollected(i),[qd(2),tetad(2),ebd(2)]);
[~, idx] = ismember(vtemp, [qd(2),tetad(2),ebd(2)]);
w(i, idx) = wtemp;
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!