Not enough input arguments.

조회 수: 9 (최근 30일)
Brady Ruth
Brady Ruth 2020년 3월 1일
답변: Sai Sri Pathuri 2020년 3월 4일
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
Walter Roberson
Walter Roberson 2020년 3월 1일
How are you invoking this code?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sai Sri Pathuri
Sai Sri Pathuri 2020년 3월 4일
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)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by