Discussion:
Scilab - check or define function %s_2_s for overloading
(too old to reply)
David McGee
2010-05-27 04:16:58 UTC
Permalink
-->clear

-->worksheet = readxls('file.xls');

-->worksheet2 = worksheet(2);

-->SampNum = worksheet2.value(:,1);

-->Time = worksheet2.value(:,2);

-->Speed = worksheet2.value(:,3);

-->Accel = worksheet2.value(:,4);

-->Distance = worksheet2.value(:,5);

-->j=size(Speed); //Defines the size of the Table
of data [Rows, Columns)

-->

-->Poly6=polyfit(Time,Speed,6); //Line of best fit

-->Poly1(1)=Poly6(7);

-->Poly1(2)=Poly6(6);

-->Poly1(3)=Poly6(5);

-->Poly1(4)=Poly6(4);

-->Poly1(5)=Poly6(3);

-->Poly1(6)=Poly6(2);

-->Poly1(7)=Poly6(1);

-->r=roots(Poly1) ; //Finds roots of 6th Degree
Polynomial

-->g=1;

-->n=1;

-->

-->[maxspeed,maxloc] = max(Speed);

-->

-->for(i=0:.25:Speed(maxloc)) //Loop that is going to find all
roots from 0 to the max speed
--> Poly1(7)=Poly1(7)-.25; //of the stalker run
--> n=1;
--> c=Poly1;
--> rootchange = roots(c);
--> for m = 1:1:6
--> if(rootchange(m)> 0) && (rootchange(m)<(Time(j(1)))) then
--> if(rootchange(m) == (rootchange(m))) then //Puts
the real roots between 0 and
--> roots6a(n,g) = rootchange(m); //the max
distance in a vector
--> n=n+1;
--> end
--> end
--> end
--> g=g+1;
-->end
!--
error 144
Undefined operation for the given operands.

check or define function %s_2_s for overloading.


I am trying to transfer code from matlab to scilab and running into
some issues, i am getting a "check or define function %s_2_s for
overloading" error and i think the cause is that scilab can't handle
the complex roots correctly when i processing through
"if(rootchange(m)> 0) && (rootchange(m)<(Time(j(1))))".

I am trying to find two real roots between 0 and the max time. I
believe i need to add another loop to pull out only my real roots from
the 6 and then allow those to process. I am running into issues of how
to enter this into my code, any ideas?

Thanks in advance,
David
Eric
2010-05-28 07:30:16 UTC
Permalink
Post by David McGee
-->clear
-->worksheet = readxls('file.xls');
-->worksheet2 = worksheet(2);
-->SampNum = worksheet2.value(:,1);
-->Time = worksheet2.value(:,2);
-->Speed = worksheet2.value(:,3);
-->Accel = worksheet2.value(:,4);
-->Distance = worksheet2.value(:,5);
-->j=size(Speed);                    //Defines the size of the Table
of data [Rows, Columns)
-->
-->Poly6=polyfit(Time,Speed,6);      //Line of best fit
-->Poly1(1)=Poly6(7);
-->Poly1(2)=Poly6(6);
-->Poly1(3)=Poly6(5);
-->Poly1(4)=Poly6(4);
-->Poly1(5)=Poly6(3);
-->Poly1(6)=Poly6(2);
-->Poly1(7)=Poly6(1);
-->r=roots(Poly1) ;                  //Finds roots of 6th Degree
Polynomial
-->g=1;
-->n=1;
-->
-->[maxspeed,maxloc] = max(Speed);
-->
-->for(i=0:.25:Speed(maxloc))        //Loop that is going to find all
roots from 0 to the max speed
-->  Poly1(7)=Poly1(7)-.25;             //of the stalker run
-->  n=1;
-->  c=Poly1;
-->  rootchange = roots(c);
-->  for m = 1:1:6
-->   if(rootchange(m)> 0) && (rootchange(m)<(Time(j(1)))) then
-->      if(rootchange(m) == (rootchange(m))) then            //Puts
the real roots between 0 and
-->      roots6a(n,g) = rootchange(m);                      //the max
distance in a vector
-->      n=n+1;
-->     end
-->   end
-->  end
-->  g=g+1;
-->end
                                                                                                                 !--
error 144
Undefined operation for the given operands.
check or define function %s_2_s for overloading.
I am trying to transfer code from matlab to scilab and running into
some issues, i am getting a "check or define function %s_2_s for
overloading" error and i think the cause is that scilab can't handle
the complex roots correctly when i processing through
"if(rootchange(m)> 0) && (rootchange(m)<(Time(j(1))))".
I am trying to find two real roots between 0 and the max time. I
believe i need to add another loop to pull out only my real roots from
the 6 and then allow those to process. I am running into issues of how
to enter this into my code, any ideas?
Thanks in advance,
David
Hi.

The problem is that Scilab cannot compare a complex (root in your
case) to 0. Neither can I!

So, if you have searching for real positive roots then you have to
perform the operation in 2 steps :
if isreal(rootchange(m)) then
if real(rootchange(m))>0 then
...

Éric.
Tim Wescott
2010-05-28 18:44:26 UTC
Permalink
Post by Eric
Post by David McGee
-->clear
-->worksheet = readxls('file.xls');
-->worksheet2 = worksheet(2);
-->SampNum = worksheet2.value(:,1);
-->Time = worksheet2.value(:,2);
-->Speed = worksheet2.value(:,3);
-->Accel = worksheet2.value(:,4);
-->Distance = worksheet2.value(:,5);
-->j=size(Speed); //Defines the size of the Table
of data [Rows, Columns)
-->
-->Poly6=polyfit(Time,Speed,6); //Line of best fit
-->Poly1(1)=Poly6(7);
-->Poly1(2)=Poly6(6);
-->Poly1(3)=Poly6(5);
-->Poly1(4)=Poly6(4);
-->Poly1(5)=Poly6(3);
-->Poly1(6)=Poly6(2);
-->Poly1(7)=Poly6(1);
-->r=roots(Poly1) ; //Finds roots of 6th Degree
Polynomial
-->g=1;
-->n=1;
-->
-->[maxspeed,maxloc] = max(Speed);
-->
-->for(i=0:.25:Speed(maxloc)) //Loop that is going to find all
roots from 0 to the max speed
--> Poly1(7)=Poly1(7)-.25; //of the stalker run
--> n=1;
--> c=Poly1;
--> rootchange = roots(c);
--> for m = 1:1:6
--> if(rootchange(m)> 0)&& (rootchange(m)<(Time(j(1)))) then
--> if(rootchange(m) == (rootchange(m))) then //Puts
the real roots between 0 and
--> roots6a(n,g) = rootchange(m); //the max
distance in a vector
--> n=n+1;
--> end
--> end
--> end
--> g=g+1;
-->end
!--
error 144
Undefined operation for the given operands.
check or define function %s_2_s for overloading.
I am trying to transfer code from matlab to scilab and running into
some issues, i am getting a "check or define function %s_2_s for
overloading" error and i think the cause is that scilab can't handle
the complex roots correctly when i processing through
"if(rootchange(m)> 0)&& (rootchange(m)<(Time(j(1))))".
I am trying to find two real roots between 0 and the max time. I
believe i need to add another loop to pull out only my real roots from
the 6 and then allow those to process. I am running into issues of how
to enter this into my code, any ideas?
Thanks in advance,
David
Hi.
The problem is that Scilab cannot compare a complex (root in your
case) to 0. Neither can I!
So, if you have searching for real positive roots then you have to
if isreal(rootchange(m)) then
if real(rootchange(m))>0 then
...
Éric.
Note that Eric's solution will miss complex roots with real positive
parts -- think hard if this is what you want or not. Note in particular
that if your _nominal_ polynomial has double real roots, finding the
roots of the _actual_ polynomial may run into numeric trouble and cough
up a pair of complex roots with a real part that is very large compared
to the imaginary part, yet which Scilab will still see as complex.

Depending on what you want, you need to do different things:

If you only care about widely distinct positive real roots then Eric's
solution is the way to go.

If you only care about the real part of the roots then use
real(rootchange(m)) > 0. I suspect that this is what Matlab did implicitly.

If you want to distinguish between "this root should have been a double
real but isn't" and "this root really is complex" then you have to
exercise some finesse in your code.
--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
k***@gmail.com
2019-06-21 05:54:25 UTC
Permalink
Post by Eric
Post by David McGee
-->clear
-->worksheet = readxls('file.xls');
-->worksheet2 = worksheet(2);
-->SampNum = worksheet2.value(:,1);
-->Time = worksheet2.value(:,2);
-->Speed = worksheet2.value(:,3);
-->Accel = worksheet2.value(:,4);
-->Distance = worksheet2.value(:,5);
-->j=size(Speed);                    //Defines the size of the Table
of data [Rows, Columns)
-->
-->Poly6=polyfit(Time,Speed,6);      //Line of best fit
-->Poly1(1)=Poly6(7);
-->Poly1(2)=Poly6(6);
-->Poly1(3)=Poly6(5);
-->Poly1(4)=Poly6(4);
-->Poly1(5)=Poly6(3);
-->Poly1(6)=Poly6(2);
-->Poly1(7)=Poly6(1);
-->r=roots(Poly1) ;                  //Finds roots of 6th Degree
Polynomial
-->g=1;
-->n=1;
-->
-->[maxspeed,maxloc] = max(Speed);
-->
-->for(i=0:.25:Speed(maxloc))        //Loop that is going to find all
roots from 0 to the max speed
-->  Poly1(7)=Poly1(7)-.25;             //of the stalker run
-->  n=1;
-->  c=Poly1;
-->  rootchange = roots(c);
-->  for m = 1:1:6
-->   if(rootchange(m)> 0) && (rootchange(m)<(Time(j(1)))) then
-->      if(rootchange(m) == (rootchange(m))) then            //Puts
the real roots between 0 and
-->      roots6a(n,g) = rootchange(m);                      //the max
distance in a vector
-->      n=n+1;
-->     end
-->   end
-->  end
-->  g=g+1;
-->end
                                                                                                                 !--
error 144
Undefined operation for the given operands.
check or define function %s_2_s for overloading.
I am trying to transfer code from matlab to scilab and running into
some issues, i am getting a "check or define function %s_2_s for
overloading" error and i think the cause is that scilab can't handle
the complex roots correctly when i processing through
"if(rootchange(m)> 0) && (rootchange(m)<(Time(j(1))))".
I am trying to find two real roots between 0 and the max time. I
believe i need to add another loop to pull out only my real roots from
the 6 and then allow those to process. I am running into issues of how
to enter this into my code, any ideas?
Thanks in advance,
David
Hi.
The problem is that Scilab cannot compare a complex (root in your
case) to 0. Neither can I!
So, if you have searching for real positive roots then you have to
if isreal(rootchange(m)) then
if real(rootchange(m))>0 then
...
Éric.
Thank you Eric,
For sharing the information. I too had same error. But now I got it cleared.

Thank you..!

s***@gmail.com
2015-10-27 06:35:54 UTC
Permalink
hai
am having a problem with the following code.....
model1 is the result of svm classifier result structure
model=[model model1]
error 144
undefined operation for the given operands
s***@gmail.com
2015-10-27 06:40:12 UTC
Permalink
for i=1:25
model1=libsvm_svmtrain(1,feturevector(i,:),'-s 2 -t 2 -g 0.004 -n 0.06')
model=[model model1]
error 144
undefined operation for the given operands

please give suggestion to clear the error....................
thanking you
s***@gmail.com
2015-10-28 04:06:53 UTC
Permalink
am having feature vector with 50X6 dimension.
i try to train the sample one by one and store the libsvm_svmtrain result in to array
it willshow the following error
svmt=[svmt mtrain]
error 144
undefined operation for the given operands
check or define function %s_f_st for overloading
please help me to solve that problem
s***@gmail.com
2016-04-01 08:05:58 UTC
Permalink
i have the the error as undefined operation for the given operands in the below code...please tell me how to solve this pbm
if nn>0 then->error in this line
l=1
else
l=0
end
Loading...