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!

do loop - vector as looping variable

Status
Not open for further replies.

chubb87

Technical User
May 17, 2010
2
GB
Hi,

I want to convert MATLAB to Fortran code and have problems replacing a for-loop, which uses a vector as looping variable.
The MATLAB code looks like this:
Code:
for m = 1:ind_Dw		        
    for c = [1 3 4 7 10 12 14 19 22 24 27] 
        Iw(:,:) = Iw(:,:) + pi*IWE(:,:,c,m)*Dw(m);                        
    end  
end

I think I cannot use sum() , because of the first 2 entries of IWE.
Can you think of a way to transform the code to Fortran?
Thank you in advance.
 
I have found it out myself:
you can do it with when you use a parameter of the sum-function:
sum(Iwe,dim=3)
and then use a vector in Iwe to index it for c
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top