The double for loop can be done in a vectorized way in a single line of code instead of 9 lines of code (this is how most MATLAB programmers would do it):
X = input("Donner une matrice dont les l'element sont ts differnets de zero");
M = X >= 0;
B = ~M .* X;
The code basically gets the positive and negative elements according to what I said in my comments. Most (I hope) MATLAB programmers would also have put comments into that code, and would have chosen more descriptive variable names so other people, like you for example, could follow the code easier and not be left scratching their head wondering what the code does.