kindly help in the conversion of fortran code to matlab

1 回表示 (過去 30 日間)
Oluwaseyi Aliu
Oluwaseyi Aliu 2020 年 4 月 10 日
コメント済み: Oluwaseyi Aliu 2020 年 4 月 10 日
  5 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 10 日
snul = 0.0;
snur = 0.0;
for j = 0:m
rnul = (th(0,j) - th(1,j)) * n;
rnur = (th(n-1,j) - th(n,j)) * n;
snul = snul + rnul;
snur = snur + rnur;
fprintf('%g %g %g\n' j/m, rnul, rnur);
end
avnl = snul / m;
avnr = snur / m;
fprintf('%g %g %g\n', ra, avnl, avnr);
I do not see any 100 x 100 matrices, not unless you are saying that th is a matrix. In fortran it is possible but not all that common to declare arrays to start from index 0, or any other index. I would want to see the statements that defined th, such as
REAL*8 th(100,100)
but it could not be exactly like that if th is a matrix being indexed at 0.
Oluwaseyi Aliu
Oluwaseyi Aliu 2020 年 4 月 10 日
sir, here is the initialisation;

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 10 日
n = 100; m = 100;
c8 = length(0:8);
f = zeros(c8, n+1, m+1);
feq = zeros(c8, n+1, m+1);
rho = zeros(c8, n+1, m+1);
w = zeros(1, c8);
cx = zeros(1, c8);
cy = zeros(1, c8);
u = zeros(n+1, m+1);
v = zeros(n+1, m+1);
g = zeros(c8, n+1, m+1);
geq = zeros(c8, n+1, m+1);
th = zeros(n+1, m+1);
i = 0;
%then some code to read the data.
%then
snul = 0.0;
snur = 0.0;
for j = 0:m
rnul = (th(1+0,1+j) - th(1+1,1+j)) * n;
rnur = (th(1+n-1,1+j) - th(1+n,1+j)) * n;
snul = snul + rnul;
snur = snur + rnur;
fprintf('%g %g %g\n' j/m, rnul, rnur);
end
avnl = snul / m;
avnr = snur / m;
fprintf('%g %g %g\n', ra, avnl, avnr);

その他の回答 (0 件)

カテゴリ

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