[Scilab-users] convert matlab code to scilab

classic Classic list List threaded Threaded
17 messages Options
der_Phil der_Phil
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] convert matlab code to scilab

Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )

Thank you,
Philipp

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

Re: convert matlab code to scilab

Hello

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?

by dummy names, e.g.

[ans,ans,Minstances_hat] = unique(B(:));

There is no equivalent mechanism in Scilab.
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )

Thank you,
Philipp

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

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

Re: convert matlab code to scilab

[ans,ans,Minstances_hat] = unique(B(:));
gives:  Wrong number of output arguments.

I also tried :
[Minstances_hat] = unique(B(:));
and get a vector.
also
[Minstances_hat,index] = unique(B(:));
seem to work.


However afterwards there is this line:
masks = reshape(Minstances_hat-1,size(B));
I try to convert via:
mask = matrix(Minstances_hat-1,size(B));
but no success.






Am Mi., 16. Okt. 2019 um 11:50 Uhr schrieb Stéphane Mottelet <[hidden email]>:

Hello

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?

by dummy names, e.g.

[ans,ans,Minstances_hat] = unique(B(:));

There is no equivalent mechanism in Scilab.
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )

Thank you,
Philipp

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

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

Re: convert matlab code to scilab

Sorry, I thought you were just asking about the tildas, not the syntax of unique() in Scilab.

Please see

https://help.scilab.org/docs/6.0.2/en_US/unique.html

vs

https://fr.mathworks.com/help/matlab/ref/unique.html

Matlab syntax [C,ia,ic] = unique(___)  with 3 outputs has no equivalent in Scilab. i.e. in Matlab, after  [C,ia,ic] = unique(A) then A=C(ic), i.e. values in ic are the indices of corresponding unique value in C.  They can be recovered with the quick and dirty following loop:

for i=1:length(a)
     ia(i)=find(a(i)==C)
end

S.

Le 16/10/2019 à 12:10, P M a écrit :
[ans,ans,Minstances_hat] = unique(B(:));
gives:  Wrong number of output arguments.

I also tried :
[Minstances_hat] = unique(B(:));
and get a vector.
also
[Minstances_hat,index] = unique(B(:));
seem to work.


However afterwards there is this line:
masks = reshape(Minstances_hat-1,size(B));
I try to convert via:
mask = matrix(Minstances_hat-1,size(B));
but no success.






Am Mi., 16. Okt. 2019 um 11:50 Uhr schrieb Stéphane Mottelet <[hidden email]>:

Hello

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?

by dummy names, e.g.

[ans,ans,Minstances_hat] = unique(B(:));

There is no equivalent mechanism in Scilab.
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )

Thank you,
Philipp

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

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

Re: convert matlab code to scilab

Sorry, in my answer the loop constructs "ic", not  "ia", i.e. the full equivalent to Matlab's "[C,ia,ic] = unique(A)" is in Scilab:

[C,ia] = unique(A)
for i=1:length(A)
    ic(i)=find(A(i)==C)
end

S.

Le 16/10/2019 à 13:19, Stéphane Mottelet a écrit :

Sorry, I thought you were just asking about the tildas, not the syntax of unique() in Scilab.

Please see

https://help.scilab.org/docs/6.0.2/en_US/unique.html

vs

https://fr.mathworks.com/help/matlab/ref/unique.html

Matlab syntax [C,ia,ic] = unique(___)  with 3 outputs has no equivalent in Scilab. i.e. in Matlab, after  [C,ia,ic] = unique(A) then A=C(ic), i.e. values in ic are the indices of corresponding unique value in C.  They can be recovered with the quick and dirty following loop:

for i=1:length(a)
     ia(i)=find(a(i)==C)
end

S.

Le 16/10/2019 à 12:10, P M a écrit :
[ans,ans,Minstances_hat] = unique(B(:));
gives:  Wrong number of output arguments.

I also tried :
[Minstances_hat] = unique(B(:));
and get a vector.
also
[Minstances_hat,index] = unique(B(:));
seem to work.


However afterwards there is this line:
masks = reshape(Minstances_hat-1,size(B));
I try to convert via:
mask = matrix(Minstances_hat-1,size(B));
but no success.






Am Mi., 16. Okt. 2019 um 11:50 Uhr schrieb Stéphane Mottelet <[hidden email]>:

Hello

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?

by dummy names, e.g.

[ans,ans,Minstances_hat] = unique(B(:));

There is no equivalent mechanism in Scilab.
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )

Thank you,
Philipp

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

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

Re: convert matlab code to scilab

Dear Stephane,

thanks for your help.
I think in my case the problem is solved just by using:
[Minstances_hat] = unique(B(:));
This gives a vector of used px-values for different objects shown in image.
Each object is defined by a single pixel value.
Since B is the B-plane of an RGB-image, it is possible to assign each pixel from the original image to an object using these values.

Thanks again,
Philipp


Am Mi., 16. Okt. 2019 um 13:27 Uhr schrieb Stéphane Mottelet <[hidden email]>:

Sorry, in my answer the loop constructs "ic", not  "ia", i.e. the full equivalent to Matlab's "[C,ia,ic] = unique(A)" is in Scilab:

[C,ia] = unique(A)
for i=1:length(A)
    ic(i)=find(A(i)==C)
end

S.

Le 16/10/2019 à 13:19, Stéphane Mottelet a écrit :

Sorry, I thought you were just asking about the tildas, not the syntax of unique() in Scilab.

Please see

https://help.scilab.org/docs/6.0.2/en_US/unique.html

vs

https://fr.mathworks.com/help/matlab/ref/unique.html

Matlab syntax [C,ia,ic] = unique(___)  with 3 outputs has no equivalent in Scilab. i.e. in Matlab, after  [C,ia,ic] = unique(A) then A=C(ic), i.e. values in ic are the indices of corresponding unique value in C.  They can be recovered with the quick and dirty following loop:

for i=1:length(a)
     ia(i)=find(a(i)==C)
end

S.

Le 16/10/2019 à 12:10, P M a écrit :
[ans,ans,Minstances_hat] = unique(B(:));
gives:  Wrong number of output arguments.

I also tried :
[Minstances_hat] = unique(B(:));
and get a vector.
also
[Minstances_hat,index] = unique(B(:));
seem to work.


However afterwards there is this line:
masks = reshape(Minstances_hat-1,size(B));
I try to convert via:
mask = matrix(Minstances_hat-1,size(B));
but no success.






Am Mi., 16. Okt. 2019 um 11:50 Uhr schrieb Stéphane Mottelet <[hidden email]>:

Hello

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?

by dummy names, e.g.

[ans,ans,Minstances_hat] = unique(B(:));

There is no equivalent mechanism in Scilab.
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )

Thank you,
Philipp

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

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

Re: convert matlab code to scilab

In reply to this post by mottelet
Le 16/10/2019 à 13:27, Stéphane Mottelet a écrit :
>
> Sorry, in my answer the loop constructs "ic", not  "ia", i.e. the full
> equivalent to Matlab's "[C,ia,ic] = unique(A)" is in Scilab:
>
> [C,ia] = unique(A)
> for i=1:length(A)
>     ic(i)=find(A(i)==C)
> end
>

ic = ones(A);
for i = 1:length(ia)
     ic(A==C(i)) = i;
end
// Check:
and(A==C(ic))

will be always (much) shorter and faster (in case of high redundancy).

Samuel

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

Re: convert matlab code to scilab

In reply to this post by mottelet
Le 16/10/2019 à 13:19, Stéphane Mottelet a écrit :

Sorry, I thought you were just asking about the tildas, not the syntax of unique() in Scilab.

Please see

https://help.scilab.org/docs/6.0.2/en_US/unique.html

vs

https://fr.mathworks.com/help/matlab/ref/unique.html

Matlab syntax [C,ia,ic] = unique(___)  with 3 outputs has no equivalent in Scilab.


If this output option is required, this request should be urgently reported on Bugzilla.
Indeed, some new unique() features have been implemented and pushed on the Scilab forge for Scilab 6.1.0,
and are pending, in answer to
http://bugzilla.scilab.org/8418 http://bugzilla.scilab.org/15522 http://bugzilla.scilab.org/15795
Such a request would challenge the third output position.
To me, the third foreseen output -- that is the vector of numbers of occurrences -- would be more useful, and faster to compute, so rather to appear before possibly ic in the output list.

Please note that ic should be computed as well in case of "r" or "c" option.

Regards
Samuel


i.e. in Matlab, after  [C,ia,ic] = unique(A) then A=C(ic), i.e. values in ic are the indices of corresponding unique value in C.  They can be recovered with the quick and dirty following loop:

for i=1:length(a)
     ia(i)=find(a(i)==C)
end

S.


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

[Scilab-users] How to convert the ~ input placeholder <= Re: convert matlab code to scilab

In reply to this post by der_Phil
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )


This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Hope reading your contributions,

Regards
Samuel


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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

Le 23/11/2019 à 15:35, Samuel Gougeon a écrit :
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));
How to replace the "~" symbol?
B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )


This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Where is the crowd of matlabers?

The page describing this feature: https://fr.mathworks.com/help/matlab/matlab_prog/ignore-function-inputs.html
But i do not clearly understand it.
Apparently, "canceling" an input is done (only?) at the function definition, not when calling it, unlike for the outputs.
If so, then ans could also be used as a replacement, meaning that anyway this input won't be used inside the function.

A test of call with Octave yields an error:

>> function [r, s] = funtest(a,b,c)
end
>> funtest(1,~,3)
parse error:
  invalid use of empty argument (~) in index expression
>>> funtest(1,~,3)
                 ^
>>

Any further insight is welcome.
Samuel


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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

Hi Samuel, 

I think your assumption likely correct on the input and the output using ~


"
You can use tilde to ignore input arguments when you define the function.
You cannot use tilde to ignore input arguments when you call the function.
You cannot use tilde to ignore output arguments when you define the function.
You can use tilde to ignore output arguments when you call the function.
If you want to be able to specify only the third argument, there must be some way for your function to disambiguate the one-input call from a call that specifies only the third input. Usually in MathWorks function this is done by specifying [] for the arguments for which the user doesn't want to specify. In that case the code would use the default value if either nargin is too small or if nargin is large enough and the specified input argument isempty.
"
From what I could think off, mat2sci conversion to replace ~ at the output arguments should always be safe. As for the input, since the tilde could not be used as input when calling function, I think there should not be any cases that need to be implemented in conversion?
Thanks.
Regards,
CL


---- On Tue, 26 Nov 2019 04:20:52 +0800 Samuel Gougeon <[hidden email]> wrote ----

Le 23/11/2019 à 15:35, Samuel Gougeon a écrit :
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));

How to replace the "~" symbol?

B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )


This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Where is the crowd of matlabers?

But i do not clearly understand it.
Apparently, "canceling" an input is done (only?) at the function definition, not when calling it, unlike for the outputs.
If so, then ans could also be used as a replacement, meaning that anyway this input won't be used inside the function.

A test of call with Octave yields an error:

>> function [r, s] = funtest(a,b,c)
end
>> funtest(1,~,3)
parse error:
  invalid use of empty argument (~) in index expression
>>> funtest(1,~,3)
                 ^
>>

Any further insight is welcome.
Samuel


_______________________________________________
users mailing list
http://lists.scilab.org/mailman/listinfo/users



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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

Hello Chin Luh,

Thanks a lot for your input.

Both cases -- input and output will have to be converted --, since the converter is also made to convert (sets of) functions definitions, not only scripts.

About the input case: Steven's answer is still not really clear to me. Doing some tests on Octave, we must anyway provide some input at calling time when  ~ is used as default input in the definition. AFAIU, this ~ could just be to make sure that no variable name used inside the function matches the name of the input argument in the function definition, since "~" alone can't be actually used as variable's name. In this case, for Scilab, any input ~ could be replaced with an improbable variable name like "%unused" or "%kwzxq", and that should do it.

Please, correct me if someone understands something else.

Best regards
Samuel

Le 26/11/2019 à 03:33, Chin Luh Tan a écrit :
Hi Samuel, 

I think your assumption likely correct on the input and the output using ~


"
You can use tilde to ignore input arguments when you define the function.
You cannot use tilde to ignore input arguments when you call the function.
You cannot use tilde to ignore output arguments when you define the function.
You can use tilde to ignore output arguments when you call the function.
If you want to be able to specify only the third argument, there must be some way for your function to disambiguate the one-input call from a call that specifies only the third input. Usually in MathWorks function this is done by specifying [] for the arguments for which the user doesn't want to specify. In that case the code would use the default value if either nargin is too small or if nargin is large enough and the specified input argument isempty.
"
From what I could think off, mat2sci conversion to replace ~ at the output arguments should always be safe. As for the input, since the tilde could not be used as input when calling function, I think there should not be any cases that need to be implemented in conversion?
Thanks.
Regards,
CL


---- On Tue, 26 Nov 2019 04:20:52 +0800 Samuel Gougeon [hidden email] wrote ----

Le 23/11/2019 à 15:35, Samuel Gougeon a écrit :
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));

How to replace the "~" symbol?

B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )


This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Where is the crowd of matlabers?

But i do not clearly understand it.
Apparently, "canceling" an input is done (only?) at the function definition, not when calling it, unlike for the outputs.
If so, then ans could also be used as a replacement, meaning that anyway this input won't be used inside the function.

A test of call with Octave yields an error:

>> function [r, s] = funtest(a,b,c)
end
>> funtest(1,~,3)
parse error:
  invalid use of empty argument (~) in index expression
>>> funtest(1,~,3)
                 ^
>>

Any further insight is welcome.
Samuel


_______________________________________________
users mailing list



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



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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

Hi Samuel, 

In fact I've not been using matlab for more than 10 years, so I try to understand this as well. 

The input tilde is still abit confusing for me as well, I am trying to understand its' usage as this page: https://octave.org/doc/v4.4.1/Ignoring-Arguments.html

function val = pick2nd (~, arg2)
  val = arg2;
endfunction

I can't see the reason why the input need to ignored in this case, is it defined but not being user due to bad user overlooked it? or is it neglected and the default value would be used?


"The tilde is only for function declaration. Matlab's mlint recommends to replace unused arguments by ~. The result is a function declared like this function output = MyFunction(a, b, ~, c). This is a very bad practice.

Since you have a function where the parameters are optional, you must call the function with empty arguments output=MyFunction(str1,str2,[],[],...,true)."

It sound to me that the input tilde is suggested by the matlab  mlint to improve the code so that the unused variable need not to pass into the function, and to improve memory management? 

So there are 2 possibilities for the input tilde :

1. used to replace unused variable in the input which defined by user, but not being used. So the mlint recomment to replace with tilde, it could be be remove possibly due to the project has been calling the functions for many time, and changing the 4th to 3rd argument might need to change a lot of codes. In this case, the %unused would be good. 

2. Tilde used to tell the function to use default value, then replacing it with % unused might cause error. 

Think we need some x-matlaber to confirm which case. 

Thanks again.

rgds,
CL 



---- On Tue, 26 Nov 2019 20:36:01 +0800 Samuel Gougeon <[hidden email]> wrote ----

Hello Chin Luh,

Thanks a lot for your input.

Both cases -- input and output will have to be converted --, since the converter is also made to convert (sets of) functions definitions, not only scripts.

About the input case: Steven's answer is still not really clear to me. Doing some tests on Octave, we must anyway provide some input at calling time when  ~ is used as default input in the definition. AFAIU, this ~ could just be to make sure that no variable name used inside the function matches the name of the input argument in the function definition, since "~" alone can't be actually used as variable's name. In this case, for Scilab, any input ~ could be replaced with an improbable variable name like "%unused" or "%kwzxq", and that should do it.

Please, correct me if someone understands something else.

Best regards
Samuel

Le 26/11/2019 à 03:33, Chin Luh Tan a écrit :


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

I think your assumption likely correct on the input and the output using ~


"
You can use tilde to ignore input arguments when you define the function.
You cannot use tilde to ignore input arguments when you call the function.
You cannot use tilde to ignore output arguments when you define the function.
You can use tilde to ignore output arguments when you call the function.
If you want to be able to specify only the third argument, there must be some way for your function to disambiguate the one-input call from a call that specifies only the third input. Usually in MathWorks function this is done by specifying [] for the arguments for which the user doesn't want to specify. In that case the code would use the default value if either nargin is too small or if nargin is large enough and the specified input argument isempty.
"
From what I could think off, mat2sci conversion to replace ~ at the output arguments should always be safe. As for the input, since the tilde could not be used as input when calling function, I think there should not be any cases that need to be implemented in conversion?
Thanks.
Regards,
CL


---- On Tue, 26 Nov 2019 04:20:52 +0800 Samuel Gougeon [hidden email] wrote ----

Le 23/11/2019 à 15:35, Samuel Gougeon a écrit :
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));


How to replace the "~" symbol?


B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )



This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Where is the crowd of matlabers?

But i do not clearly understand it.
Apparently, "canceling" an input is done (only?) at the function definition, not when calling it, unlike for the outputs.
If so, then ans could also be used as a replacement, meaning that anyway this input won't be used inside the function.

A test of call with Octave yields an error:

>> function [r, s] = funtest(a,b,c)
end
>> funtest(1,~,3)
parse error:
  invalid use of empty argument (~) in index expression
>>> funtest(1,~,3)
                 ^
>>

Any further insight is welcome.
Samuel


_______________________________________________
users mailing list



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




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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

Le 26/11/2019 à 16:15, Chin Luh Tan a écrit :
2. Tilde used to tell the function to use default value, then replacing it with % unused might cause error.


But then, even if such a global default value exists, assigned to and reachable from what, since ~ can't be a variable name?


Think we need some x-matlaber to confirm which case.


Right, but case #2 looks quite improbable.

Regards
Samuel



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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

In reply to this post by Chin Luh Tan
Hello,

Or when you have to write a function following a specific prototype ( graphic events, optim, ode, ...)

If I would write a function that call another, I have to specify a prototype to allow user to call my function.
But in some case, the final user does not need all parameters so he can replace unused inputs by ~.
I think that only syntactic sugar.

example:
function for_each(iterable, fn)
    for i=1:size(iterable, "*")
        fn(iterable(i), i, iterable); //item, index, array
    end
endfunction

Users can define fn like this if tthey only need item and don't want to use index and whole array
function my_func(a, ~, ~)
    //blabla
end

I don't say that's essential :p
That's my understanding
Antoine
Le 26/11/2019 à 16:15, Chin Luh Tan a écrit :
Hi Samuel, 

In fact I've not been using matlab for more than 10 years, so I try to understand this as well. 

The input tilde is still abit confusing for me as well, I am trying to understand its' usage as this page: https://octave.org/doc/v4.4.1/Ignoring-Arguments.html

function val = pick2nd (~, arg2)
  val = arg2;
endfunction

I can't see the reason why the input need to ignored in this case, is it defined but not being user due to bad user overlooked it? or is it neglected and the default value would be used?


"The tilde is only for function declaration. Matlab's mlint recommends to replace unused arguments by ~. The result is a function declared like this function output = MyFunction(a, b, ~, c). This is a very bad practice.

Since you have a function where the parameters are optional, you must call the function with empty arguments output=MyFunction(str1,str2,[],[],...,true)."

It sound to me that the input tilde is suggested by the matlab  mlint to improve the code so that the unused variable need not to pass into the function, and to improve memory management? 

So there are 2 possibilities for the input tilde :

1. used to replace unused variable in the input which defined by user, but not being used. So the mlint recomment to replace with tilde, it could be be remove possibly due to the project has been calling the functions for many time, and changing the 4th to 3rd argument might need to change a lot of codes. In this case, the %unused would be good. 

2. Tilde used to tell the function to use default value, then replacing it with % unused might cause error. 

Think we need some x-matlaber to confirm which case. 

Thanks again.

rgds,
CL 



---- On Tue, 26 Nov 2019 20:36:01 +0800 Samuel Gougeon <[hidden email]> wrote ----

Hello Chin Luh,

Thanks a lot for your input.

Both cases -- input and output will have to be converted --, since the converter is also made to convert (sets of) functions definitions, not only scripts.

About the input case: Steven's answer is still not really clear to me. Doing some tests on Octave, we must anyway provide some input at calling time when  ~ is used as default input in the definition. AFAIU, this ~ could just be to make sure that no variable name used inside the function matches the name of the input argument in the function definition, since "~" alone can't be actually used as variable's name. In this case, for Scilab, any input ~ could be replaced with an improbable variable name like "%unused" or "%kwzxq", and that should do it.

Please, correct me if someone understands something else.

Best regards
Samuel

Le 26/11/2019 à 03:33, Chin Luh Tan a écrit :


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

I think your assumption likely correct on the input and the output using ~


"
You can use tilde to ignore input arguments when you define the function.
You cannot use tilde to ignore input arguments when you call the function.
You cannot use tilde to ignore output arguments when you define the function.
You can use tilde to ignore output arguments when you call the function.
If you want to be able to specify only the third argument, there must be some way for your function to disambiguate the one-input call from a call that specifies only the third input. Usually in MathWorks function this is done by specifying [] for the arguments for which the user doesn't want to specify. In that case the code would use the default value if either nargin is too small or if nargin is large enough and the specified input argument isempty.
"
From what I could think off, mat2sci conversion to replace ~ at the output arguments should always be safe. As for the input, since the tilde could not be used as input when calling function, I think there should not be any cases that need to be implemented in conversion?
Thanks.
Regards,
CL


---- On Tue, 26 Nov 2019 04:20:52 +0800 Samuel Gougeon [hidden email] wrote ----

Le 23/11/2019 à 15:35, Samuel Gougeon a écrit :
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));


How to replace the "~" symbol?


B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )



This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Where is the crowd of matlabers?

But i do not clearly understand it.
Apparently, "canceling" an input is done (only?) at the function definition, not when calling it, unlike for the outputs.
If so, then ans could also be used as a replacement, meaning that anyway this input won't be used inside the function.

A test of call with Octave yields an error:

>> function [r, s] = funtest(a,b,c)
end
>> funtest(1,~,3)
parse error:
  invalid use of empty argument (~) in index expression
>>> funtest(1,~,3)
                 ^
>>

Any further insight is welcome.
Samuel


_______________________________________________
users mailing list



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




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


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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

In reply to this post by Chin Luh Tan

This is only speculation: Could the tilde be used in some cases where some arguments that are not the last ones are optional, and the function definition includes some way to check if the corresponding argument has or has nor been provided?

I've noticed in some cases Scilab allows just to omit the argument keeping the commas.

Regards,

Federico Miyara

On 26/11/2019 12:15, Chin Luh Tan wrote:
Hi Samuel, 

In fact I've not been using matlab for more than 10 years, so I try to understand this as well. 

The input tilde is still abit confusing for me as well, I am trying to understand its' usage as this page: https://octave.org/doc/v4.4.1/Ignoring-Arguments.html

function val = pick2nd (~, arg2)
  val = arg2;
endfunction

I can't see the reason why the input need to ignored in this case, is it defined but not being user due to bad user overlooked it? or is it neglected and the default value would be used?


"The tilde is only for function declaration. Matlab's mlint recommends to replace unused arguments by ~. The result is a function declared like this function output = MyFunction(a, b, ~, c). This is a very bad practice.

Since you have a function where the parameters are optional, you must call the function with empty arguments output=MyFunction(str1,str2,[],[],...,true)."

It sound to me that the input tilde is suggested by the matlab  mlint to improve the code so that the unused variable need not to pass into the function, and to improve memory management? 

So there are 2 possibilities for the input tilde :

1. used to replace unused variable in the input which defined by user, but not being used. So the mlint recomment to replace with tilde, it could be be remove possibly due to the project has been calling the functions for many time, and changing the 4th to 3rd argument might need to change a lot of codes. In this case, the %unused would be good. 

2. Tilde used to tell the function to use default value, then replacing it with % unused might cause error. 

Think we need some x-matlaber to confirm which case. 

Thanks again.

rgds,
CL 



---- On Tue, 26 Nov 2019 20:36:01 +0800 Samuel Gougeon <[hidden email]> wrote ----

Hello Chin Luh,

Thanks a lot for your input.

Both cases -- input and output will have to be converted --, since the converter is also made to convert (sets of) functions definitions, not only scripts.

About the input case: Steven's answer is still not really clear to me. Doing some tests on Octave, we must anyway provide some input at calling time when  ~ is used as default input in the definition. AFAIU, this ~ could just be to make sure that no variable name used inside the function matches the name of the input argument in the function definition, since "~" alone can't be actually used as variable's name. In this case, for Scilab, any input ~ could be replaced with an improbable variable name like "%unused" or "%kwzxq", and that should do it.

Please, correct me if someone understands something else.

Best regards
Samuel

Le 26/11/2019 à 03:33, Chin Luh Tan a écrit :


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

I think your assumption likely correct on the input and the output using ~


"
You can use tilde to ignore input arguments when you define the function.
You cannot use tilde to ignore input arguments when you call the function.
You cannot use tilde to ignore output arguments when you define the function.
You can use tilde to ignore output arguments when you call the function.
If you want to be able to specify only the third argument, there must be some way for your function to disambiguate the one-input call from a call that specifies only the third input. Usually in MathWorks function this is done by specifying [] for the arguments for which the user doesn't want to specify. In that case the code would use the default value if either nargin is too small or if nargin is large enough and the specified input argument isempty.
"
From what I could think off, mat2sci conversion to replace ~ at the output arguments should always be safe. As for the input, since the tilde could not be used as input when calling function, I think there should not be any cases that need to be implemented in conversion?
Thanks.
Regards,
CL


---- On Tue, 26 Nov 2019 04:20:52 +0800 Samuel Gougeon [hidden email] wrote ----

Le 23/11/2019 à 15:35, Samuel Gougeon a écrit :
Hello Philipp, and to all (former ;-) matlabers,

Le 16/10/2019 à 11:46, P M a écrit :
Dear experts,

trying to convert a matlab code to scilab I come across following line:
[~,~,Minstances_hat] = unique(B(:));


How to replace the "~" symbol?


B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )



This issue is now reported as bug 16250.

Solving this issue would improve the converter.
I may contribute to solve it. However, I do not use to use Matlab or Octave. So i don't know how the ~ placeholder set in the list of inputs is processed inside the called function. This message is a call for information about this topic.

Ignoring an output is trivial. As suggested by Stéphane, the ans variable is a good candidate as replacement for ~,
just as a fake recipient, as in "[~, ia] = unique(A)"   =>  "[ans, ia] = unique(A)"

The meaning of ignoring an input is a priori completely different, at least from a Scilab point of view.

This leads to the fact that, on the "function ..." line, the converter will have to distinguish the list of inputs from the list of outputs, and then process the same ~ character in 2 different ways.
This processing would have to run also when the "function ..." line is split on several rows with the "..." continuation marks.

First, i will need an actual example of function call with ~ in the input list, runnable in Octave.
Any compact suggestion is welcome.
At least 2 use cases are expected: one calling a function written in Octave/Matlab language (improperly called "macros" in Scilab), the other one calling a hard-coded function.

Let's consider the first case, with a "macro":

  • What does  the ~ sent placeholder pass to the function? How is it detected/detectable inside the macro ?
  • How is it processed by the function? Is there a generic default processing, as replacing it with the empty matrix [], or whatever else?

Where is the crowd of matlabers?

But i do not clearly understand it.
Apparently, "canceling" an input is done (only?) at the function definition, not when calling it, unlike for the outputs.
If so, then ans could also be used as a replacement, meaning that anyway this input won't be used inside the function.

A test of call with Octave yields an error:

>> function [r, s] = funtest(a,b,c)
end
>> funtest(1,~,3)
parse error:
  invalid use of empty argument (~) in index expression
>>> funtest(1,~,3)
                 ^
>>

Any further insight is welcome.
Samuel


_______________________________________________
users mailing list



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




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


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

Re: How to convert the ~ input placeholder <= Re: convert matlab code to scilab

In reply to this post by Samuel GOUGEON
Hi Samuel,

"But then, even if such a global default value exists, assigned to and reachable from what, since ~ can't be a variable name?
Think we need some x-matlaber to confirm which case.
Right, but case #2 looks quite improbable."

--> i keep mixing up with built-in functions for this case. With user defined function, you're totally right.


Antoine,

"Or when you have to write a function following a specific prototype ( graphic events, optim, ode, ...)"

--> Right, think this is also the reason why the matlab mlint according to the forum suggesting the user to replace the tilde with the unused variable. 


Federico,

"This is only speculation: Could the tilde be used in some cases where some arguments that are not the last ones are optional, and the function definition includes some way to check if the corresponding argument has or has nor been provided?
I've noticed in some cases Scilab allows just to omit the argument keeping the commas."

I can't be sure on the first one, whether the argument is really used in the user-defined function, but for the second, i assume keep the commas means sth like my_fun(a,'','',b), this actually still pass the empty string to the function, whether it has been used as empty string, or it is used to indicated the use of default value, depending on the function definition.    

rgds,
CL



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