Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Matlab code to fortran 95 code

Status
Not open for further replies.

vincent1984

Technical User
Oct 1, 2009
1
GB
Hi,

I am new to fortran programming. I am trying to convert the following matlab code to fortran. Can somebody help? Thanks!

si = 1; k = 1;
for i = 1:30
for j = 1:10
ZL(k,si:si+2) = [1, 0, 2];
k = k+1;
end
si = si+3;
end

What I did was trying to 3 dimensions arrays. But kinda lost halfway.

program test
real(kind=2), dimension:),:) :: ZL
si=1
k=1
do i = 1,30
do j = 1,10
ZL(k,si) = 1
ZL(k,si+1) = 0
ZL(k,si+2) = 2
k=k+1
end do
si=si+3
end do

end program test

Many thanks for your help.

Vincent
 
Declare ZL as

real, dimension(300,90):: ZL

The problem is what does matlab do with the rest of the array? Are all the elements initialized to zero to start with? If they are, then you'll need to do that before you start filling it up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top