# Error using sym/subs>normalize, Error in sym/subs>mupadsubs, Error in sym/subs

조회 수: 13(최근 30일)
Antonia Juliane Busch 2021년 7월 6일
답변: Tanmay Das 2021년 8월 6일
Hi,
I want to generate a jacobian matrix (12x24) and run into trouble when trying to substitute my vectors.
syms x_s y_s R_s
syms vx_s [1 12]
syms vy_s [1 12]
B = jacobian([sqrt((x_s+vx_s).^2+(y_s+vy_s).^2)-R_s], [vx_s,vy_s]);
B = double(subs(B,{x_s,vx_s,y_s,vy_s,R_s},{x,vx,y,vy,R}));
My vx and vy vectors are 12x1, as well as x and y.
I get the following error:
"Error using sym/subs>normalize (line 231)
"Entries in second argument must be scalar.
"[X2,Y2,symX,symY] = normalize(X,Y); %#ok
"Error in sym/subs (line 145)
" B = double(subs(B,{x_s,vx_s,y_s,vy_s,R_s},{x,vx,y,vy,R}));
Is there any workaround for this?

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

### 답변(1개)

Tanmay Das 2021년 8월 6일
subs() can accept an array of variables as its second parameter, and another array the same size as the third parameter, and does a substitution of scalars according to corresponding positions.
subs() can also accept a cell array of variables for the second parameter, and a cell array the same size as the third parameter, and will do a simultaneous substitution of the (possibly array) contents of the cell for the corresponding variable.
But subs() cannot accept a cell array that contains multiple non-scalar arrays for the second parameter. Each cell entry must be scalar.
You can refer to this link for further information. Also, you can go through subs Documentation.
With respect to the question, you can try the following:
B = double(subs(B,[x_s,vx_s,y_s,vy_s,R_s],[x,vx,y,vy,R]));
B = double(subs(B,{x_s,vx_s,y_s,vy_s,R_s},{x,vx,y,vy,R});

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

R2020b

### Community Treasure Hunt

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

Start Hunting!