Scilab
Scilab - Submatrix incorrectly defined
Posts  1 - 1  of  1
krock4
I am taking some code i created in matlab and trying to convert it to
Scilab and am running into some issues:
The code is below:
clc
clear
worksheet = readxls('LTE101.xls');
worksheet2 = worksheet(2);
SampNum = worksheet2.value(:,1); //Defines Sample Number in own
column
x = worksheet2.value(:,2); //Defines Time in own
column
y = worksheet2.value(:,3); //Defines Speed in own
column
z = worksheet2.value(:,4); //Defines Acceleration in own
column
j=size(Speed); //Defines the size of the Table of
data [Rows, Columns)
Poly6=polyfit(x,y,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;
roots6a=zeros(40,2);
[maxspeed,maxloc] = max(y);
for(i=0:.25:x(maxloc)) //Loop that is going to find all roots
from 0 to the max speed
Poly1(7)=Poly1-.25; //of the stalker run
n=1;
c=Poly1;
rootchange = roots(c)
//roots6(:,g)=rootchange' //dont think is used
for m = 1:1:6
if((rootchange(m)> 0 && (rootchange(m)<(x(j(1)))))
if(rootchange(m) == real(rootchange(m)))) //Puts the
real roots between 0 and
roots6a(n,g) = rootchange(m)'; //the max
distance in a vector
end
end
end
g=g+1;
end

I am creating a loop to find the exact x value from 0 to the max y. I
tried using solve in matlab but it gave me a garbage forumla that does
not work. My next step was to subtract .25 from the polynomial to find
the roots because it will do the same thing. The code works fine in
matlab and i have changed what i need to before the loop so finding
the roots work. When i am in the loop i get an error saying "submatrix
incorrectly defined". Does anyone know why this occuring?
Save
Cancel
Reply
 
x
OK