Not enough input arguments.

9 visualizaciones (últimos 30 días)
Brady Ruth
Brady Ruth el 1 de Mzo. de 2020
Respondida: Sai Sri Pathuri el 4 de Mzo. de 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!
  1 comentario
Walter Roberson
Walter Roberson el 1 de Mzo. de 2020
How are you invoking this code?

Iniciar sesión para comentar.

Respuestas (1)

Sai Sri Pathuri
Sai Sri Pathuri el 4 de Mzo. de 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)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by