not enough input arguments

조회 수: 3 (최근 30일)
aarthy reddy R
aarthy reddy R 2019년 9월 4일
댓글: Guillaume 2019년 9월 12일
function test(num1, num2,small,s)
load (small, num1, num2)
s = sum(num1, num2)
end
this the code for this i'm getting these errors
Not enough input arguments.
Error in test (line 3)
load (small, num1, num2)

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 4일
편집: KALYAN ACHARJYA 2019년 9월 4일
I assumed that num1 and num2 are number
function s=test(num1, num2)
s=num1+num2;
end
Save the above function as test.m file name, and pass the inputs arguments form main scripts or command window, like as follows
Command Window:
>> result=test(4,6)
result =
10
You have to pass the inputs arguments from differnt Matlab scripts to Matlab test.m function file.
see here
  댓글 수: 5
aarthy reddy R
aarthy reddy R 2019년 9월 12일
편집: aarthy reddy R 2019년 9월 12일
i am having error only in line 2 because of load
the error is :Error using load
Unable to read file 's'. No such file or directory.
Error in test (line 2)
load s
but i have imported the s file still dont know ..... please look into the picture i have attached
function out = test(num1, num2)
load s
out = num1 + num2;
end
i want to know how to load an excel sheet so those values can be used in this function
Guillaume
Guillaume 2019년 9월 12일
load s
will load the content of a file called s into the workspace of your function. It won't do anything else.
but i have imported the s
I'm not sure what that means exactly. But Whatever you've done outside of the function is irrelevant if you don't pass the stuff as inputs to the function
i want to know how to load an excel sheet so those values can be used in this function
This has absolutely nothing to do with load. You'd use xlsread or preferably readtable to import data from excel, then pass the data as an input to the function.
%data = readtable('C:\somewhere\somefile.xlsx'); %import data from excel as a table
result = test(data.Var1, data.Var2) %call the function passing two columns from the imported data

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by