On May 27, 6:16 am, David McGee <mcgee.dav...@gmail.com> wrote:
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 Tableof 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 speedthe real roots between 0 and
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
roots6a(n,g) = rootchange(m); //the maxdistance 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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 38:46:54 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,543 |