Undefined f tand for input arg sym

I receive error "Undefined function 'tand' for input arguments of type 'sym' at line:
v = ...* tand(ea/2));
I tried replacing this 'ea' with any numerical value which resulted in the same error message but for 'cosd':
x = cosd(ea)...
any help would be much appreciated
ea = m + (180/pi20)* ec * sind(m)* (1 + ec *cos(m));
keeplooping = true;
while ea > 0.005
E1 = (ea - (180/pi20)* ec *sind(ea)-m)/(1-ec *cosd(ea));
E1 = ea;
keeplooping;
if ea <= 0.005
keeplooping = false
return
end
end
v = 2*atand((sqrt(1+ec))* tand(ea/2));
r = (a *(1-(ec^2))/(1+ec* cosd(v)));
x = cosd(ea) - ec;
y = sind(ea) * sqrt(1 - ec* ec);
r = sqrt(x*x + y*y);
v = atand2(y,x);

 Réponse acceptée

Walter Roberson
Walter Roberson le 3 Juin 2017
For symbolic inputs, there is no tand(), atand(), atand2(), cosd(), acosd(), sind(), or asind() .
You need to convert the argument to radians yourself, or define sind and so on yourself. For example,
Pi = sym('pi');
sinD = @(x) sin(x*Pi/180);
cosD = @(x) cos(x*Pi/180);
tanD = @(x) tan(x*Pi/180);
atanD = @(x) atan(x) * 180/Pi;
atanD2 = @(y,x) atan2(y, x) * 180/Pi;
ea = m + (180/pi20)* ec * sinD(m)* (1 + ec * cosD(m)); %corrected from original, which had cos(m)
keeplooping = true;
while ea > 0.005
E1 = (ea - (180/pi20)* ec * sinD(ea)-m)/(1 - ec * cosD(ea));
E1 = ea;
keeplooping;
if ea <= 0.005
keeplooping = false
return
end
end
v = 2 * atanD((sqrt(1+ec))* tanD(ea/2));
r = (a *(1-(ec^2))/(1+ec* cosD(v)));
x = cosD(ea) - ec;
y = sinD(ea) * sqrt(1 - ec* ec);
r = sqrt(x*x + y*y);
v = atanD2(y,x);

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by