Write a Scilab program to create a square matrix called sequential matrix whose elements are sequentially numbered. Here is what the program should do:Please enter a positive integer: -3You entered a negative number! Please try again.Execution done.Please enter a positive integer: 8A =1. 2. 3. 4. 5. 6. 7. 8.9. 10. 11. 12. 13. 14. 15. 16.17. 18. 19. 20. 21. 22. 23. 24.25. 26. 27. 28. 29. 30. 31. 32.33. 34. 35. 36. 37. 38. 39. 40.41. 42. 43. 44. 45. 46. 47. 48.49. 50. 51. 52. 53. 54. 55. 56.57. 58. 59. 60. 61. 62. 63. 64.

Respuesta :

Answer:

The code, following up the instructions is given below.

Explanation:

//taking input data which should be a positive number

positive_number = input("Enter a positive number:- ");

//if conditional statement to check if the number input is truly positive

if positive_number < 0 then

   //printing message for negative input

   disp("You entered a negative number. Please, try again.")

else

   //printing message for positive input

   disp("The number you had entered is positive")

   A = []

   //nested for loop for sequential matrix creation

   for i = 1:positive_number

       for j = 1:positive_number

           //if for 2 to n rows creation

           if i>1 then

               A(i,j) = A(i-1,j)+positive_number

           //logic for 1st for of matrix

           else

               A(i,j) = i*j

           end

       end

   end

   //displaying matrix

   disp(A)

   //writting matrix into editor.dat file

   fprintfMat('C:\Users\Maximus\Desktop\editor.dat', A, "%4f");

   //closing file

   mclose('all')

end

ACCESS MORE
EDU ACCESS