Matlab m files and questions following
Show older comments
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
on 14 Aug 2013
You forgot to tag your question as homework
David Sanchez
on 14 Aug 2013
don't worry. I did it for you
Answers (2)
Walter Roberson
on 14 Aug 2013
0 votes
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
on 14 Aug 2013
Walter Roberson
on 14 Aug 2013
I do not give out complete answers to homework questions.
John
on 14 Aug 2013
0 votes
4 Comments
Walter Roberson
on 14 Aug 2013
You may wish to have another look. You have used %% in the middle of the line, but % is the character that starts comments.
John
on 14 Aug 2013
John
on 14 Aug 2013
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".
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!