Its showing Not enough input arguments. Error in sum2 (line 2) m(:,3) = m(:,1) + m(:,2);

Hi, I'm very new to MATLAB and I am having some trouble. Lots of people have had the same problem but nobody seems to be able to explain or solve it in plain English. Could somebody please explain what this error is and how to fix it?
My function is :
function sum2(m)
m(:,3) = m(:,1) + m(:,2);
fprintf('\n Summation of Columns\n');
m(:,3)'
end
An i am getting error like Not enough input arguments.
Error in sum2 (line 2)
m(:,3) = m(:,1) + m(:,2);
please help me !!
its urgent.

Answers (1)

I think you are running the code/ function straight away using hit button or F5 key. You are not supposed to do that. You need to be in the directory where the function is saved and provide its input and then call the function.
m = rand(5,2) ; % some ddummy data for demo
sum2(m) % now call the function

Categories

Find more on Functions in Help Center and File Exchange

Products

Release

R2017a

Asked:

on 23 Feb 2022

Commented:

on 23 Feb 2022

Community Treasure Hunt

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

Start Hunting!