DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert MATLAB program to Diadem script

Brad:

 

I'm at a loss as to how to convert this function from Matlab to Diadem...any suggestions?  In Matlab it would convert the number to a string

 

Akj=num2str(j) ',' num2str(j)];%write the subscripts as strings with a comma to serparate rows and columns

0 Kudos
Message 11 of 14
(3,003 Views)

Hi jgabe,

 

Here's a start for you.  You loop For i = 1 to imax, the concatenation operator is "&", the string constant character is ", every if needs a then, the comment character is ' etc.:

 

'fill the matrices of simultaneous equations
n=0
for i = 1 to (nfil-1)
    for j = (i+1) to nfil
        Aij = "[" & i & "," & j & "]" 'write the subscripts as strings with a comma to serparate rows and columns
        n = n + 1
        nn = 0
        for ii = 1 to (nfil-2)
             for jj = (ii+1) to nfil
                 for kk = (jj+1) to nfil
                     nn = nn + 1
                     Bii = CStr(ii) 'write the subscripts as strings
                     Bjj = CStr(jj)
                     Bkk = CStr(kk)
                     if strcomp(Aij, "[" & Bii & "," & Bjj & "]") then 'compare subscripts as strings with row and column separated by a comma
                         MatUR(n,nn) = MatUR(n,nn) + 1
                         MatLL(nn,n) = 1
                     elseif strcomp(Aij, "[" & Bjj & "," & Bii & "]") then
                         MatLL(nn,n) = -1
                     elseif strcomp(Aij, "[" & Bjj & "," & Bkk & "]") then
                         MatUR(n,nn) = MatUR(n,nn) + 1
                         MatLL(nn,n) = 1
                      elseif strcomp(Aij, "[" & Bkk & "," & Bjj & "]") then
                         MatUR(n,nn) = MatUR(n,nn) - 1
                         MatLL(nn,n) = -1
                     elseif strcomp(Aij, "[" & Bkk & "," & Bii & "]") then
                         MatUR(n,nn) = MatUR(n,nn) + 1
                         MatLL(nn,n) = 1
                     elseif strcomp(Aij, "[" & Bii & "," & Bkk & "]") then
                         MatUR(n,nn) = MatUR(n,nn) - 1
                         MatLL(nn,n) = -1
                     end if
                 next
             next
        next
    next
next

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 12 of 14
(2,977 Views)

thanks Brad!  Your awesome!

0 Kudos
Message 13 of 14
(2,975 Views)

Hi jgabe,

 

I expect more questions, this is really just the first step, but hopefully it'll get you jumpstarted some.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 14 of 14
(2,963 Views)