Matlab m files and questions following
3 views (last 30 days)
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
Answers (2)
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)
John
on 14 Aug 2013
4 Comments
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".
See Also
Categories
Find more on Matrix Indexing 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!