完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
老师给留的作业 用matlab操作 新手什么都不会啊!!!求指导
请问这个程序该怎样写!!!真心求教 Water tank example: r = input('Enter the radius of the tank base (in meters):'); if ( r <= 0 ), error( ‘Radius must be positive' ); end h = input('Enter the height of the tank (in meters):'); if ( h <= 0 ), error( ‘Height must be positive' ); end w = input('Enter the amount of water (in m3):'); if ( w <= 0 ), error( ‘Amount of water must be positive' ); endcapacity = pi * r^2 * h; space = capacity - w; if ( space > 0 ), disp( [ 'There is ' num2str(space) ' m3 extra space' ] ); else disp( 'Tank is full' ); end |
|
相关推荐
|
|
这个程序有些小问题,修改后,基本上是可以运行的.
r = input('Enter the radius of the tank base (in meters):'); if ( r <= 0 ), error('Radius must be positive' ); end h = input('Enter the height of the tank (in meters):'); if ( h <= 0 ), error('Height must be positive' ); end w = input('Enter the amount of water (in m3):'); if ( w <= 0 ) error('Amount of water must be positive' ); end capacity = pi * r^2 * h; space = capacity - w; if ( space > 0 ), disp( [ 'There is ' num2str(space) ' m3 extra space' ] ); else disp( 'Tank is full' ); end |
|
|
|
|
|
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-12 07:33 , Processed in 0.522169 second(s), Total 78, Slave 58 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191