首页 > 解决方案 > 我如何使用我创建的第二个函数?

问题描述

当我想调用我在第 12 行创建的第二个函数时,它给了我一个错误(赋值右侧的值未定义)

function cosaprox
   clc, clear
   %d es el incremento y c sera la aproximacion del coseno
   d = pi/100;
   c = 0;
   tol = 0.2;
   i = 0;
   flag = true;
   %Aproximacion del cos
   while flag
      %Iteracion de la sumatoria
      x=facto (2*i)
      i+=1
      if abs(c - cos(2*pi))>= tol
         flag = false
      else
      endif
      
   endwhile
disp (c)
   
end 
function facto (x)
   if x==0;
      x=1;
   endif
   for h = 1:x-1
   x = x*h;
endfor
end

标签: octave

解决方案


推荐阅读