Not enough input argumaents

Hi, I am very new to matlab and I am getting that 'not enough input arguments when typing this.
function [sum]=add(x,y)
w=x+y;
disp(w);
end

답변 (2개)

M
M 2019년 7월 9일
편집: M 2019년 7월 9일

0 개 추천

It depends on how you call this function, try to call if from the command window :
x = 1;
y = 2;
s = add(x,y);
And then you should get an error, think about how the sum variable is calculated.

댓글 수: 2

hayyan shaikh
hayyan shaikh 2019년 7월 9일
WhatsApp Image 2019-07-09 at 6.58.35 PM.jpeg
hayyan shaikh
hayyan shaikh 2019년 7월 9일
i want the answer of the objective mention above in the pictutre
madhan ravi
madhan ravi 2019년 7월 9일
편집: madhan ravi 2019년 7월 9일

0 개 추천

https://in.mathworks.com/help/matlab/ref/function.html - I suggest you to read it for better understanding and further usage
x = 5; % example values
y = 2;
Result = Add(x,y)
% simply call it
function w = Add(x,y) % save the function in a separate file named as Add.m , note the name of the file should be same as the function name
w=x+y;
disp(w); %% redundant
end
Note: Don't name variables which are in-built functions of MATLAB.

댓글 수: 6

hayyan shaikh
hayyan shaikh 2019년 7월 9일
WhatsApp Image 2019-07-09 at 6.58.35 PM.jpeg
hayyan shaikh
hayyan shaikh 2019년 7월 9일
actually this is my practical & i had to write out the coding here using "Function" , so i need help regarding this
madhan ravi
madhan ravi 2019년 7월 9일
What's wrong with the code in the answer??
hayyan shaikh
hayyan shaikh 2019년 7월 9일
WhatsApp Image 2019-07-09 at 7.16.24 PM.jpeg
hayyan shaikh
hayyan shaikh 2019년 7월 9일
you can see my friend had also use the same coding and he had got the result but i am getting error
madhan ravi
madhan ravi 2019년 7월 9일
Clearly you need to know the basics of MATLAB

이 질문은 마감되었습니다.

질문:

2019년 7월 9일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by