[Scilab-users] extracting elements of a matrix

Samuel Gougeon sgougeon at free.fr
Sat Jan 23 22:17:45 CET 2016


Le 23/01/2016 17:43, fujimoto2005 a écrit :
> Let X be a m×n matrix and f(i) is a column index for the ith row.
> I want to get a m×1 vector y where y(i)=X(i,f(i)) for 1<=i<=m.
> Is there any method to get y other than  the following code?
> for i=1:m
> 	y(i)=X(i,f(i));
> end
Yes:
y = X((f-1)*m+i)

Regards
Samuel Gougeon




More information about the users mailing list