# [ncl-talk] Convert Matlab code to NCL

Dennis Shea shea at ucar.edu
Fri Oct 6 11:08:24 MDT 2017

```A person sent me the following offline:

do m=4,0,1
R(:,:,:,m) = dim_sum_n_Wrap(Q(:,:,:,m::,m::,m::),(/3,4,5/))
if m.lt.4 then
R(:,:,:,m) = R(:,:,:,m) - dim_sum_n_Wrap(R(:,:,:,(m+1)::),3)
end if
end do

On Thu, Oct 5, 2017 at 5:37 PM, <Arnold.Sullivan at csiro.au> wrote:

> Dear all ncl users,
>
>
>
> Could someone help me to convert Matlab code using sum to NCL
>
>
>
> *R is [time] [lat] [lon] [m1]*
>
>
>
> *Q is [time] [lat] [lon] [m1] [m2] [m3]*
>
>
>
> *For m=5:-1:1*
>
> *    R(:,:,:,m) = sum( sum( sum( Q(:,:,:,m:end,m:end,m:end), 4), 5), 6);*
>
> *    if m < 5*
>
> *        R(:,:,:,m) = R(:,:,:,m) - sum( R(:,:,:,(m+1):end), 4);*
>
> *end*
>
> *end*
>
>
>
> Is that the same way to use dim_sum_n_Wrap ?
>
>
>
> Regards,
>
>
>
> Arnold
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171006/00952a3b/attachment.html>
```