這個FORTRAN轉MATLAB的程式誰能幫個忙

我很努力的看不過還是看不懂,而且老師又急著要所以上來請教

$DEBUG

PROGRAM SD

DIMENSION DATA(45,45)

OPEN (5,FILE='DATA.DAT')

DO 50 K=1,45

READ (5,*) (DATA(K,L),L=1,45)

50 CONTINUE

SUM=0.

DO 10 I=1,45

DO 20 J=1,45

SUM=SUM+DATA(I,J)

20 CONTINUE

10 CONTINUE

AVG=SUM/(45*45)

S=0.

DO 30 II=1,45

DO 40 JJ=1,45

S=S+(DATA(II,JJ)-AVG)**2

40 CONTINUE

30 CONTINUE

A1=S/(45*45)

SD1=SQRT(A1)

WRITE (*,*) SD1

END

2 Answers

Rating
  • Chaos
    Lv 7
    1 decade ago
    Favorite Answer

    有餘力就幫你改寫一點,以下存成sd.m

    function SD1=sd

    data=load 'DATA.DAT' -ascii

    AVG=sum(sum(data(1:45,1:45)))/45/45;

    S=0;

    for I=1:45,

    for J=1:45,

    S=S+(data(I,J)-AVG)^2;

    end

    end

    A1=S/45/45;

    SD1=sqrt(A1)

    Source(s): 教學經驗
  • 1 decade ago

    謝謝妳

Still have questions? Get your answers by asking now.