Matlab symbolic variables depending on time "t" and call of symbolic vector elements
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
    Mohamed Amine Chaaleb
 2015 年 2 月 18 日
  
    
    
    
    
    コメント済み: Mohamed Amine Chaaleb
 2015 年 2 月 21 日
            Hi everybody :)
I have the following problem :
syms t x(t) y(t) z(t) theta1(t) theta2(t)
Y = [0 cos(theta1);1 sin(theta2)] * [x y]'
now the first problem is that when I call the first element of the vector V with the command "V(1)" I does't become the first element of the vecotr V but rather the hole vector with 1 instead of t, I mean :
cos(theta1(1))*conj(y(1))
conj(x(1)) + conj(y(1))*sin(theta2(1))
but what I want is this :
cos(theta1(t))*conj(y(t))
I mean only the first element which depends on t that I defined at the first of the script .
now the second little problem is that I want to give to theta1 and the other symbolic variables a start value but when I write this :
theta1(0) = 5 I become an error :
Error using symfun>validateArgNames (line 165) Second input must be a scalar or vector of unique symbolic variables.
Error in symfun (line 42) y.vars = validateArgNames(inputs);
Error in sym/subsasgn (line 1640) C = symfun(B,[inds{:}]);
Error in test (line 9) theta1(0)=5
thx for helping me !! :)
0 件のコメント
採用された回答
  Mischa Kim
    
      
 2015 年 2 月 18 日
        
      編集済み: Mischa Kim
    
      
 2015 年 2 月 18 日
  
      Mohamed, to your first question: use instead
 Y = [0 cos(theta1);1 sin(theta2)] * [x; y]  % note the last semi-colon
 Y =
        cos(theta1(t))*y(t)
 x(t) + sin(theta2(t))*y(t)
At that point you can start substituting values. E.g.
 subs(Y,{theta1},{0})
 ans =
                       y(t)
 x(t) + sin(theta2(t))*y(t)
Does that help?
5 件のコメント
  Mischa Kim
    
      
 2015 年 2 月 20 日
				OK. Yes you can, but it is a bit cumbersome. The challenge is that it is not possible to create an array of symfuns, as far as I am aware.
 Y  = [0 cos(theta1);1 sin(theta2)] * [x; y];
 Y  = Y(t);               % convert symfun to sym...
 Y1fun = symfun(Y(1),t);  % ...and convert back to symfun
 Y1fun(3)
 ans =
 y(3)*cos(theta1(3))
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

