数学实验第一讲.pptVIP

  • 5
  • 0
  • 约1.63万字
  • 约 111页
  • 2019-07-16 发布于四川
  • 举报
* Gongqu 当有三个或更多的选择时: if 关系表达式(1) {statments}(1) elseif 关系表达式(2) {statments}(2) ... elseif 关系表达式(n) {statments}(n) else {statments}(n+1) end 例如,可用以下程序得到符号函数。 function y=SIGN(x) if x0 y=-1; elseif x==0 y=0; else y=1; end * Gongqu 已知任意两个多项式(不一定同阶)的系数,求两个多项式的和。 if-else-end结构 ? if-else-end结构 * Gongqu function f=sumpoly(p1,p2) n=abs(length(p1)-length(p2)); if length(p1)length(p2) p12=[p1,zeros(1,n)]; p22=p2; elseif length(p1)length(p2) p22=[p2,zeros(1,n)]; p12=p1; end f=p12+p22; if-else-end结构 返 回 * Gongqu switch lower(NAME) case {zhanghua, lijiang}, disp( He com

文档评论(0)

1亿VIP精品文档

相关文档