Okay, so I am confident I get this, hence answering my own question.
When you want to remove a row OR a column in Scilab, you can assign it to []. The following example illustrates how this works.
Consider the matrix
A=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
which prints in the console as
A =
1. 2. 3. 4.
5. 6. 7. 8.
9. 10. 11. 12.
13. 14. 15. 16.
If you want to remove the first row, the command is
A(1,:)=[]
A =
5. 6. 7. 8.
9. 10. 11. 12.
13. 14. 15. 16.
You simply assign the first row to the empty matrix. Similarly if you wanted to remove the 2nd column, you assign it to empty matrix:
A(:,2)=[]
A =
5. 7. 8.
9. 11. 12.
13. 15. 16.
(Note that the operation is performed on the updated matrix--i.e the 1st row removed)
But if you want to remove the 1st row and the 2nd column, you can't write:
A(1,2)=[]
Scilab says:
Submatrix incorrectly defined.
Here is an alternate solution using assignment to the empty matrix:
General idea: We perform 2 operations one by one: deleting the 1st row and then the ith column.
Posting code for just the else part:
else
s=0
first_row_removed=A //taking a backup of A and then...
first_row_removed(1,:)=[] //...removing the 1st row
for i=1:order
column_i_removed=first_row_removed //taking a backup of the 1st-row-removed matrix...
column_i_removed(:,i)=[] //... and then deleting column i
s=s+((-1)^(i+1))*A(1,i)*take_detm(column_i_removed); //recursive call
end
determinant=s
end //of else
An important thing to note is that performing the assignment to the empty matrix makes changes in the original matrix itself. Hence for every iteration of the for loop, we must make sure that we perform remove-ith-column operation on the 1st-row-removed matrix and not on the matrix which had its ith column deleted in the previous for loop iteration.
Hence the line
column_i_removed=first_row_removed
must be inside the for loop.