[問題] 程式碼有問題已回收

看板MATLAB作者 (curious)時間16年前 (2009/12/04 20:37), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
請問各位 我打以下程式碼 但他一直說定義不完全 >> function [y, yy, yyy]=parabol_cam(phi,phi_in,beta_range,direct,travel,rpm) % code = 2 % [y, yy, yyy]=parabol_cam(phi,phi_in,beta_range,direct,travel,rpm) % phi=cam angle, degrees % phi_in=starting cam angle, degrees % beta_range=motion range, degrees % direct=motion type; +1 for upward, -1 for downward % travel=the follower travels(=1 for a unit of travel) % rpm=cam rotation speed, rpm(=0 for not effective) % Example: [y, yy, yyy]=parabol_cam(150,120,60,1,0.8,0) d2r=pi/180; th=phi*d2r;thinit=phi_in*d2r; beta=beta_range*d2r; speed=rpm*2*pi/60;if rpm==0, speed=1;end; theta=th-thinit; thmed=thinit+beta/2; thx=theta/beta; if direct==1, if th<thmed y=2*thx^2; yyy=4/beta/beta; yy=yyy*th; else y=1-2*(1-thx)^2; yy=4/beta*(1-thx); yyy=-4/beta/beta; end else if th<thmed y=1-2*thx^2; yyy=-4/beta/beta; yy=yyy*th; else y=2*(1-thx)^2; yy=-4/beta*(1-thx); yyy=4/beta/beta; end end y=y*travel; yy=yy*speed*travel; yyy=yyy*speed*speed*travel; 執行結果 ??? function [y, yy, yyy]=parabol_cam(phi,phi_in,beta_range,direct,travel,rpm) | Error: Function definitions are not permitted at the prompt or in scripts. 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.59

12/04 21:56, , 1F
請存成m-file
12/04 21:56, 1F
文章代碼(AID): #1B6GAd7N (MATLAB)