How to create 3d array equivalent to fortran dimension?

Hello all, I have this fortran code
dimension x(2,m,n)
where m=100, n=40 Now how to convert this into the matlab?

 採用された回答

Jan
Jan 2016 年 5 月 16 日

0 投票

Perhaps you mean:
x = zeros(2, m, n)

2 件のコメント

adi kul
adi kul 2016 年 5 月 16 日
Thank you. It does create 2XmXn array but this gives zeros of the defined size matrix
In fortran this is not the case. Please guide.
adi kul
adi kul 2016 年 5 月 16 日
Sorry. This helped me. Thank you. Now I am facing a new issue.
My fortran code says
j=1,m
g(j) = t(k,i,j)*dcos(anglezx) - t(j)*dsin(anglezx)
How can I do this 3d multiplication in 1d in matlab. If I use this as it is I get size error for g(j) as matlab cosiders it as 1x1 while my t(k,i,j) is a 2xmxn sized matrix.

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

その他の回答 (1 件)

Farrukh Mazhar
Farrukh Mazhar 2019 年 2 月 20 日

0 投票

this code probably is wrong the correct Fortran code would be like
do k=1,aa
do i=1,n
do j=1,m
g(j) = t(k,i,j)*dcos(anglezx) - t(j)*dsin(anglezx)
enddo
enddo
enddo
Please change to
for k=1:aa
do i=1:n
do j=1:m
g(k,j,i) = t(k,i,j)*dcos(anglezx) - t(j)*dsin(anglezx)
end
end
end

カテゴリ

ヘルプ センター および File ExchangeFortran with MATLAB についてさらに検索

質問済み:

2016 年 5 月 16 日

回答済み:

2019 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by