有人可以告诉我我的代码有什么问题吗?
sinlaw('?',150,30,39.8)
parse error near line 30 of file
'endfunction' command matched by 'endif'
function [phi] = sinlaw (A,a,B,b)
If A==('?')
a=deg2rad(a)
b=deg2rad(b)
A=(B/sin(b))*sin(a)
endif
if(a=='?')
a=deg2rad(asin((A/B)*sin(b)))
endif
endfunction
答案 0 :(得分:1)
虽然语法检查与endif
If...
错字随意test it here。
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 )