抑制输出MATLAB

抑制输出MATLAB,matlab,Matlab,我的代码输出会给出if、确切的_答案,然后是一个包含N个条目的向量输出。我不确定如何抑制该条目。例如,它看起来如下所示: exact_answer = 0.2642 If = 0.1882 ans = 0 0.1637 0.2681 0.3293 0.3595 0.3679 我不想要答案输出- function g = LaplaceTransform(s,N) % define function p

我的代码输出会给出if、确切的_答案,然后是一个包含N个条目的向量输出。我不确定如何抑制该条目。例如,它看起来如下所示:

exact_answer =

    0.2642


If =

    0.1882


ans =

         0    0.1637    0.2681    0.3293    0.3595    0.3679
我不想要答案输出-

function g = LaplaceTransform(s,N)
        % define function parameters
        a=0; 
        b=1;
        h=(b-a)/N;
        x = 0:h:1;
        % define function
        g = ff(x).*exp(-s*x);

% compute the exact answer of the integral
exact_answer=antiderivative(b,s)-antiderivative(a,s)
% compute the composite trapezoid sum
If=0;
for i=1:(N-1)
    If=If+g(i).*h;
end;
If=If+g(1).*h/2+g(N).*h/2;
If

ans
显示,因为您呼叫

LaplaceTransform(bla, blabla)
而不是

LaplaceTransform(bla, blabla);
调用函数时缺少分号)

精确答案出现,因为您的线路

exact_answer=antiderivative(b,s)-antiderivative(a,s)
也缺少分号,您应该有

exact_answer=antiderivative(b,s)-antiderivative(a,s);

这是你在这里问的关于你的这个问题的第4个问题(有些被删除,所以没有绝对计数)。在询问更多问题之前,请阅读一本关于MATLAB编程的介绍性书籍。