fuction [detofA,x]=solveAxB(t) error why

fuction [detofA,x]=solveAxB(t)
%SOLVEAxB: solve the linear system Ax=B
%this function solveAxB.m
%to call this function type:
%[detofA,x]=solveAxB(t)
%where t is the input parameter and
%detofA andare out puts detrmined of A
%and the unknown X
A=[5,2*t,t;3,6,2*t-1;2,t-1,3*t];
% above line creates coeff matrix A
B=[2,3,5]'; %this creates column vector B
detofA=det(A);%find the dermint of A
X=A\B; %find x

2 Comments

What is the error message? What parameter are you passing to it?
the erroe is that Error in ==> solveAxB fuction [detofA,x]=solveAxB(t)

Sign in to comment.

Answers (1)

muhammad - the problem is with the function signature
fuction [detofA,x]=solveAxB(t)
You have written fuction instead of function. Change the above to
function [detofA,x]=solveAxB(t)
and ensure that the file is saved as solveAxB.m. Note that when you call this function, it will be from the Command Window (or from within another script) doing something like
t = 42;
[detOfA,x] = solveAxB(t);
Since this function requires an input parameter you must supply it with one (in this case, 42). If you were to try and run this function (from the editor) you will get an error like
Error using solveAxB (line 9)
Not enough input arguments.

Tags

No tags entered yet.

Asked:

on 12 Mar 2016

Commented:

on 15 Mar 2016

Community Treasure Hunt

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

Start Hunting!