[Scilab-users] Matlab to Scilab code query

classic Classic list List threaded Threaded
4 messages Options
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Matlab to Scilab code query

Hello all,

I have a query regarding some code I tweaked to run under Scilab from the original Matlab version (attached both here). Both give the same result for subplot 1 (upper view), but the lower subplot has different results and I cannot see where the difference is occurring. It is just the one variable 'tecsub' that is different:

Output of Matlab code run under Octave 4.2.1
Time to run: ~75 seconds (Windows 8, 4 Gb RAM)

# name: tecsub
# type: matrix
# rows: 1
# columns: 10
 -139.3527934186596 842.87653145532 1025.945665042103 1146.425533894219 1203.652906805529 1059.430317329787 1537.631029751693 1733.651048106937 1764.494015134895 1550.652338116411
 
Output of Scilab version of code - 6.0.1
Time run(same system): barely 2 seconds
 
(-296.995965224827    1048.6694829971702    1170.395004249152    1144.5753136299015    1041.8907922680846    1221.1924318672322    1539.48125001601    1589.201708899888    1558.7010635930444    1708.2955099225785)

Also note how fast the code runs under Scilab compared to Octave running broadly the same code. Didn't get to tweak the second subplot axis back to 0 depth at top, but here I'm interested in the values. If someone can see where the variance is great.

Cheers
Lester

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

Holt_Backstrip.m (8K) Download Attachment
Backstrip1 (7K) Download Attachment
Holt_Backstrip.sce (9K) Download Attachment
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Matlab to Scilab code query

Hi Lester,

 

Your problem seems to be fixed by defining in Scilab:

 

//sl = fliplr(sl);

sl = sl($:-1:1); // Scilab reverse

 

//Wd = fliplr(Wd);

Wd = Wd($:-1:1); // Scilab reverse

 

For vectors, the L-R flip should be instead reverse order.

 

Regarding the massive time savings of Scilab 6 vs Octave, I see it on the first time the code is run but not afterwards.

Did not test enough.

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Matlab to Scilab code query

Actually, the root problem is not in Matlab fliplr(A) being replaced by A(:,$:-1:1), as per Scilab help file.

According to Matlab help:

“If A is a row vector, then fliplr(A) returns a vector of the same length with the order of its elements reversed. If A is a column vector, then fliplr(A) returns A. unchanged.”

 

The root problem was that the two vectors below in your script were considered row vectors by Octave and column vectors by Scilab.

 

Regards,

Rafael

 

From: users [mailto:[hidden email]] On Behalf Of Rafael Guerra
Sent: Tuesday, July 17, 2018 4:08 PM
To: Users mailing list for Scilab <[hidden email]>
Subject: Re: [Scilab-users] Matlab to Scilab code query

 

Hi Lester,

 

Your problem seems to be fixed by defining in Scilab:

 

//sl = fliplr(sl);

sl = sl($:-1:1); // Scilab reverse

 

//Wd = fliplr(Wd);

Wd = Wd($:-1:1); // Scilab reverse

 

For vectors, the L-R flip should be instead reverse order.

 

Regarding the massive time savings of Scilab 6 vs Octave, I see it on the first time the code is run but not afterwards.

Did not test enough.

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

Re: Matlab to Scilab code query

Thanks for the clarification, good to know the subtle details.


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users