converting from fortran code to matlab

3 ビュー (過去 30 日間)
Mohamed Ibrahim
Mohamed Ibrahim 2015 年 10 月 15 日
編集済み: dpb 2015 年 10 月 15 日
I am beginner in matlab, i have code that needed to be converted to matlab could any one help me to do that the fortran code is:
IF ($t .EQ. 0) THEN
Urohr=0
Up=28
ENDIF
Urohr=Urohr+($wm * $dt * Up)
Uidsref=($idref*cos(Urohr))-($iqref*sin(Urohr))
Uiqsref=($idref*sin(Urohr))+($iqref*cos(Urohr))
$IaRef=Uidsref
$IbRef=(-.5*Uidsref)+(.866*Uiqsref)
$IcRef=(-.5*Uidsref)-(.866*Uiqsref)

回答 (1 件)

dpb
dpb 2015 年 10 月 15 日
'$' isn't a legal Fortran character (nor is it allowed in a Matlab variable name); you'll have to fix that up. I don't know whether your code page caused a translation error in pasting the code or whether the code may have been run through a preprocessor and those references replaced by some other character or sequence of characters but you'll need whatever that is resolved.
Other than that, it is essentially Matlab syntax with the substitution of lowercase and end instead of ENDIF
  3 件のコメント
Walter Roberson
Walter Roberson 2015 年 10 月 15 日
$ is allowed in Fortran format specifications, and in comments, but not otherwise (not even in the latest draft for Fortran 2015)
dpb
dpb 2015 年 10 月 15 日
編集済み: dpb 2015 年 10 月 15 日
Well, yes, but none of those allowable places are extant in the code snippet given so seemed futile to mention in this context...
I wonder if perhaps it was/is a kludge to work around different precision variables by preprocessor substitution, maybe...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFortran with MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by