有人可以告诉我我的代码有什么问题吗?
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
虽然语法检查抱怨匹配endif
问题实际上出在If...
typo
随意地在这里测试一下 https://tio.run/##VY/LDsIgEEX3fMXdSQ3x1ZjoojHtbxgX9KUkhhqt@vl4gdjHsGCGM3Mv01W9/jTOtW9b9aazOD9u5oIML2Pv@guJXEErFAolEiHAMC1yZBnZ4rTgI2JocKxurrunriWrAZQzUI4g90CiwNrbBcSzjAUFEBobW5t2cPaA3jNn7z21DvP8OXWLUTCqJ1NNXv/FhYgbS2C73yhvoJAySY@rA6cGGkBoGalzPw.
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 )
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)