Matlab m files and questions following

3 views (last 30 days)
John
John on 14 Aug 2013
hey, i have a matlab question that I couldnt find help for. It asks the following:
1)write a function m file called modify.m to input two n by n matrices.
a)Check that the set of columns of each matrix is a basis of the column space
of the matrix
(b) Output the change of basis matrix from the first basis to the second.
(c) Provide an appropriate help message.
(d) Test your function on the following :
A=[ 1 3; 2 4]
How do I go by doing exactly this? I understand to create an m file you need to do something like this:?
function R=modify(A,B)
[n n]=size(A)
[n n]=size(B)
if det(A)%%det(B)!=0
C=inv(B)*A
is this correct?
  2 Comments
David Sanchez
David Sanchez on 14 Aug 2013
You forgot to tag your question as homework
David Sanchez
David Sanchez on 14 Aug 2013
don't worry. I did it for you

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 14 Aug 2013
In the code you show, there is no value in making those size() calls. You are throwing away the result of the first size() call (overwriting it with the result of the second), and you do nothing with the result of the second size() call.
You have not done error checking to be sure the arrays are the same size, non-empty, and an appropriate data type. You have also not done the check required in 1(a)
  2 Comments
John
John on 14 Aug 2013
Hey walter. Thanks for replying. Will you please write the correct code? I am not fimiliar with matlab at all.

Sign in to comment.


John
John on 14 Aug 2013
I thought the determinant are the checks. It follows after the if statement.
  4 Comments
John
John on 14 Aug 2013
Please anyone else willing to answer. Please outline what I should do mainly. Tried with matlab but have no clue.
Daniel Shub
Daniel Shub on 14 Aug 2013
@John you should edit your question to demonstrate a specific problem and ask a specific question. You wrote a function. What happens when you run it? What do you expect to happen? Then you can ask "Why when I do A do I get B instead of C like I expected".

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!