Matlab m files and questions following

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

You forgot to tag your question as homework
don't worry. I did it for you

Sign in to comment.

Answers (2)

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

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

You may wish to have another look. You have used %% in the middle of the line, but % is the character that starts comments.
Walter, I didnt ask you to provide a complete solution. Just SOME. I tried this and couldnt get further with matlab. I only ask you to show me the way out since I tried this and have no one else to go to. Thanks.
Please anyone else willing to answer. Please outline what I should do mainly. Tried with matlab but have no clue.
@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.

Categories

Asked:

on 14 Aug 2013

Community Treasure Hunt

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

Start Hunting!