Octave 八度音程-';endfunction';与'匹配的命令;endif';

Octave 八度音程-';endfunction';与'匹配的命令;endif';,octave,Octave,有人能告诉我我的代码出了什么问题吗 sinlaw('?',150,30,39.8) parse error near line 30 of file 'endfunction' command matched by 'endif' 函数[phi]=sinlaw(A,A,B,B) 如果A==(“?”) a=deg2rad(a) b=deg2rad(b) A=(B/sin(B))*sin(A) 恩迪夫 如果(a=='?') a=deg2rad(asin((a/B)*sin(B)

有人能告诉我我的代码出了什么问题吗

   sinlaw('?',150,30,39.8)
   parse error near line 30 of file 
   'endfunction' command matched by 'endif'
函数[phi]=sinlaw(A,A,B,B)
如果A==(“?”)
a=deg2rad(a)
b=deg2rad(b)
A=(B/sin(B))*sin(A)
恩迪夫
如果(a=='?')
a=deg2rad(asin((a/B)*sin(B)))
恩迪夫
端功能

而语法检查抱怨是否匹配了
endif

问题实际上在于
If…
打字错误 请随意


倍频程输入区分大小写。“
If
”必须写为“
If
”才能被识别为
If
。我已经在示例中添加了倍频程语法突出显示:现在您可以清楚地看到,顶部的“If”被视为一种不同的标记。如果您的编辑器支持语法高亮显示(例如,octave build tin编辑器),那么这可能会提醒您输入错误。(另外,适当的缩进也会有帮助!)谢谢,对不起,请立即给你投票。我没有注意到按钮
function [phi] = sinlaw ( A, a, B, b )

    if A == ( '?' )                                 %% this works, not the "If"
       a  = deg2rad( a )
       b  = deg2rad( b )
       A  = ( B / sin( b ) ) * sin( a ) 
    endif

    if ( a == '?' )
         a = deg2rad( asin( ( A / B ) * sin( b ) ) )
    endif

endfunction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sinlaw(  150, '?', 30, 39.8 )
sinlaw(  '?', 150, 30, 39.8 )