Not enough input arguments.

1 view (last 30 days)
Brady Ruth
Brady Ruth on 1 Mar 2020
Answered: Sai Sri Pathuri on 4 Mar 2020
Hi y'all, I'm trying to create a function that can determine the rank, pivots, and free variables of a matrix without just using rank(A). I thought my code looked good but whenever I try to run it it tells me I need more input arguments. I'm pretty new to Matlab and cannot figure out what I is wrong with it. My code is here:
function csolve(A)
[num_rows, num_cols] = size(A);
free_vars = 1:1:num_cols;
pivots = [];
R = rref(A);
for i = 1:1:num_rows
for j = 1:1:num_cols
if R(i,j) == 1
pivots = [pivots, j];
break
end
rank = length(pivots);
free_vars = free_vars(pivots);
end
end
fprintf("The rank of the coefficient matrix is " + rank + ".");
fprintf("Pivot variables: " + pivots);
fprintf("Free variables: " + free_vars);
Like I said, I'm new so it's very possible that this code will not work correctly anyways, if you can find what input I need to add, that would be greatly appreciated!

Answers (1)

Sai Sri Pathuri
Sai Sri Pathuri on 4 Mar 2020
I assume you called the function as below or hit the Run button, which results in the error 'Not enough input arguments'.
csolve
The function expects a matrix as an input. Since you are not passing any input, the error is being thrown. Define matrix A for which the rank, pivots, and free variables are to be determined and call the function in command window as
csolve(A)

Community Treasure Hunt

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

Start Hunting!