且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Octave-'endfunction' 命令与 'endif' 匹配

更新时间:2021-08-02 04:00:13

虽然语法检查抱怨 endif

随时此处测试它.

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 )