(GNU Octave / MATLAB)'x'被指定为方程的变量,但是仍然没有指定x

时间:2016-07-28 12:38:15

标签: matlab octave

'x'指定为@(x),但错误消息不断出现。

    <i> function F = drawCFRPgraph0726(X, y, E, I, A, G, r, c, m)
    t(1) = pi/2+0.0000001;
    i = 1;
     while t(i)<pi
     disp(t(i));
     for k = 1:500
     L(k) = 0.000001*k;
     dvdx(x) = @(x) ((x/3-L(k)/2)(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(x-L(k))+x*       (L(k)/2-x/3)(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(x-L(k))^2+x(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(3*(x-L(k)))+x*(y-t(i)+pi/2)*(x/3-L(k)/2)/(x-L)+x*t(i)-x*y-pi*x/2)/L(k);
     d2vdx2(x) = @(x) ((-2*x/3+L(k))*(c*L(k)*m/(c+r)-x*(t(i)-y-pi/2))/(x-L(k))^2+x*(2*x/3-L(k))*(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(x-L(k))^3-2*x*(c*L(k)*m/(c+r)-x*(t(i)-y-pi/2))/(3(x-L(k))^2)+2*(c*L(k)*m/(c+r)-x*(t(i)-y-pi/2))/(3*(x-L(k)))+(y-t(i)+pi/2)*(2*x/3-L(k))/(x-L(k))+x*(-2*x/3+L(k))*(y-t(i)+pi/2)/(x-L(k))^2+2*x*(y-t(i)+1.5708)/(3*(x-L(k)))+t(i)-y-pi/2)^2/L(k)^2;
     A(k) = quad(dvdx(x), 0, L(k));
     B(k) = quad(dv2dx2(x), 0, L(k));</i>

1 个答案:

答案 0 :(得分:5)

你错误地定义了匿名函数。

要正确定义它们,您应该:

dvdx = @(x) ((x/3-L(k)/2)(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(x-L(k))+x*       (L(k)/2-x/3)(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(x-L(k))^2+x(c*L(k)*m/(c+r)-x(t(i)-y-pi/2))/(3*(x-L(k)))+x*(y-t(i)+pi/2)*(x/3-L(k)/2)/(x-L)+x*t(i)-x*y-pi*x/2)/L(k);

这意味着:现在dvdx是一个带有1个参数(@(x))的函数,并使用以下等式((x/2-L(k) ...对其求值。但是x没有在外部定义,同样的方式X, y, E, I, A, G, r, c, m没有在外部定义,只是在函数内部。

quad的第一个输入是一个函数,函数不是dvdx(x)而只是dvdx