Welcome To Home of Information

MATLAB function that takes a matrix as argument and then ask from the user

Posted in
No comments
Thursday, August 7, 2014 By Anonymous



MATLAB function that takes a matrix as argument and then ask from the user that which operation you want to perform i.e. (+, -, *) then show the result. For example, if user asks to perform addition then program should show sum of all the values of that matrix. MATRIX CAN BE OF ANY DIMENSION.
function Question10()
    Rows = input('Enter Rows for Matrix A: ');                    %getting no. of rows from user
    Columns = input('Enter Columns for Matrix B: ');                    %getting no. of columns from user
   
    Matrix = zeros(Rows, Columns);                         %initializing matrix
   
    for i=1 : Rows                                             %for loop
        for j=1 : Columns
            fprintf('Enter Value in Row %d Column %d = ', i, j);
            Matrix(i, j) = input('');
        End                     %ending loop
    End                         %ending
   
    disp(' ');
    disp('+');
    disp('-');                  %displayig options
    disp('*');
    disp('/');
    option = input('\nWhich Operation Do you want to Perform: ', 's');     %displayig options
   
    Result = Operations(Matrix, option);
    disp(Result);                      %displayig result
end


Related posts

0 comments:

About the Author

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque volutpat volutpat nibh nec posuere. Donec auctor arcut pretium consequat.

Proudly Powered by Blogger.