error saying not enough input arguments?

조회 수: 1 (최근 30일)
Olivia
Olivia 2024년 8월 10일
편집: Torsten 2024년 8월 10일
function newmatrix = rootflow(conversion)
a = [-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0; 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 .6 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 .253 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 .147 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 .16 0 0 -1 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 .84 0 0 0 0 0 -1 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 ; 0 0 0 0 0 0 0 0 0 0 0 0 .09 0 0 -1 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 .94 0 0 -1 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 .91 0 0 0 0 0 -1 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 .06 0 0 0 0 0 -1 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1];
b = zeros(21,1);
b(1,1) = -1360.777;
a5 = a; %new variable for a so old one isn't altered
newmatrix = zeros(1001,1); %creates matrix that I will add the values from the for loop
rowcounter = 1; %counts rows
for i = (conversion) %will go through all the conversion values
a5(7,4) = 1-i; %changes the values that are affected by the conversion
a5(8,4) = i*0.631;
a5(9,4) = i*0.368;
x5 = a5\b; %new solution matrix for each conversion value
total_recycle_flowrate_5 = 2.20462*(x5(19) + x5(20));%new recycle flowrate for each conversion value
newmatrix(rowcounter) = total_recycle_flowrate_5;%the new recycle flowrate is added to newmatrix
rowcounter = rowcounter + 1; %rowcounter moves to next row so recylce flowrate will be added to next row
end
end
>> rootflow
Not enough input arguments.
Error in rootflow (line 8)
for i = (conversion) %will go through all the conversion values

답변 (1개)

Sam Chak
Sam Chak 2024년 8월 10일
편집: Sam Chak 2024년 8월 10일
You must pass some values into the 'rootflow()' function.
function newmatrix = rootflow(conversion)
a = [-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0; 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 .6 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 .253 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 .147 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 .16 0 0 -1 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 .84 0 0 0 0 0 -1 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 ; 0 0 0 0 0 0 0 0 0 0 0 0 .09 0 0 -1 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 .94 0 0 -1 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 .91 0 0 0 0 0 -1 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 .06 0 0 0 0 0 -1 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1];
b = zeros(21,1);
b(1,1) = -1360.777;
a5 = a; %new variable for a so old one isn't altered
newmatrix = zeros(1001,1); %creates matrix that I will add the values from the for loop
rowcounter = 1; %counts rows
for i = (conversion) %will go through all the conversion values
a5(7,4) = 1-i; %changes the values that are affected by the conversion
a5(8,4) = i*0.631;
a5(9,4) = i*0.368;
x5 = a5\b; %new solution matrix for each conversion value
total_recycle_flowrate_5 = 2.20462*(x5(19) + x5(20));%new recycle flowrate for each conversion value
newmatrix(rowcounter) = total_recycle_flowrate_5;%the new recycle flowrate is added to newmatrix
rowcounter = rowcounter + 1; %rowcounter moves to next row so recylce flowrate will be added to next row
end
end
newmatrix = rootflow(0:.001:1)
newmatrix = 1001x1
1.0e+04 * 3.0333 3.0001 2.9675 2.9355 2.9042 2.8735 2.8433 2.8137 2.7847 2.7562
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  댓글 수: 1
Umeshraja
Umeshraja 2024년 8월 10일
Adding on to that, use end keyword to terminate both the function and for loop.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by