- Substitute values into the symbolic expression using subs so the result is a number, containing no symbolic variables.
- Preallocate plcl to be a symbolic array using sym(zeros(3, 1)).
i confuse using syms variable
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
shahin hashemi
el 15 de En. de 2019
Respondida: Steven Lord
el 15 de En. de 2019
dear all
i run the following code :
clc
clear all
N=6; % number of disks
L=0.08; % the length of each segment
x = sym('x', [1 3*N], 'real');
for i=1:N
alf(i)=x(1,3*i-2);
bet(i)=x(1,3*i-1);
gam(i)=x(1,3*i);
tet(i)=sqrt((alf(i))^2+(bet(i))^2);
calf(i)=cos(alf(i)); salf(i)=sin(alf(i));
cbet(i)=cos(bet(i)); sbet(i)=sin(bet(i));
cgam(i)=cos(gam(i)); sgam(i)=sin(gam(i));
ctet(i)=cos(tet(i)); stet(i)=sin(tet(i)); vtet(i)=1-cos(tet(i));
end
plcl(:,1)=zeros(3,1); % rows for xyz position, cols for disk, 3rd dim for time
for i=1:N
plcl(:,i+1)= L*[(bet(i)*vtet(i))/(tet(i)^2);-(alf(i)*vtet(i))/(tet(i)^2 );(stet(i))/tet(i)];
end
and i got this error :
The following error occurred converting from sym to double:
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in ENERJYplus1 (line 36)
plcl(:,i+1)=
L*[(bet(i)*vtet(i))/(tet(i)^2);-(alf(i)*vtet(i))/(tet(i)^2
);(stet(i))/tet(i)];
i really appreciated if someone help me that y i got this error and what s the solotion ?
and i should mention that i need to use diff for R at my next step
and i think i could use this code in past ver of matlab
0 comentarios
Respuesta aceptada
Steven Lord
el 15 de En. de 2019
The symbolic expression on the right side of the equals sign:
L*[(bet(i)*vtet(i))/(tet(i)^2);-(alf(i)*vtet(i))/(tet(i)^2);(stet(i))/tet(i)];
still contains a symbolic variable. When you try assigning into the double array plcl (which is double because it was preallocated using zeros) MATLAB can't evaluate the symbolic expression to get a number. It's as though I asked you the numeric value of sin(z) without telling you what z is. Is it -1, 1, or something inbetween?
Your two main choices:
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!