Welcome To Home of Information

Write a MATLAB function func1 which takes a matrix A as argument then add 5 in each element of matrix A and store the result in B matrix then pass matrix B to func2 which will show the matrix B.

Posted in
No comments
Wednesday, July 30, 2014 By Anonymous




Write a MATLAB function func1 which takes a matrix A as argument then add 5 in each element of matrix A and store the result in B matrix then pass matrix B to func2 which will show the matrix B.

Solution:

function Question 2()

    Rows=input(‘Enter rows for a matrix:’);
    Coloumns = input(‘Enter coloms for matrix B:’);
   
    MatA = zeros(Rows,Columns);
   
    for i=1 : 1 : Rows
        for j=1 : 1 : Columns;
            fprontf(‘ Enter value in row %d Column %d = ‘, i,j);
            MatA(i,j) = input(‘’);
        end
    end
   
    MatB=func1(MatA);
    Func2(MatB);
end

func1:
function [Argument_MatB] = func1(Parameter_MatA)
    Argument_MatB = Parameter_MatA + 5;
end

func2:
functoin func2(Parameter_matB)
    disp(parameter_MatB);
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.