function [ y ] = EquationDerivs( x, w )
%EQUATIONDERIVS Summary of this function goes here
% Detailed explanation goes here
if (w==0.2)
y = ((0.2*cos(x))+1)/((0.2+cos(x))^2);
elseif (w==0.3)
y = ((0.3*cos(x))+1)/((0.3+cos(x))^2);
elseif (w==0.4)
y = ((0.4*cos(x))+1)/((0.4+cos(x))^2);
elseif (w==0.5)
y = ((0.5*cos(x))+1)/((0.5+cos(x))^2);
elseif (w==0.6)
y = ((0.6*cos(x))+1)/((0.6+cos(x))^2);
elseif (w==0.7)
y = ((0.7*cos(x))+1)/((0.7+cos(x))^2);
elseif (w==0.8)
y = ((0.8*cos(x))+1)/((0.8+cos(x))^2);
elseif (w==0.9)
y = ((0.9*cos(x))+1)/((0.9+cos(x))^2);
elseif (w==1)
y = 1/(1+cos(x));
else
y = -115;
end
end
So I have this simple code to tell matlab when to use a dertiviate of a function based on the value of W and for whatever reason on w==0.3, and a few others the code jumps to the else statement anyone know why? I'll post my command window below but notice how when W is equal to 0.3, 0.6, or 0.9 is just jumps to my else statement?
for W = 0.2:0.1:1
theta = degtorad(30);
yP = feval(@EquationDerivs,theta,W)
end
yP =
1.0324
yP =
-115
yP =
0.8400
yP =
0.7679
yP =
-115
yP =
0.6549
yP =
0.6099
yP =
-115
yP =
0.5359
>>