size function says not enough input arguments

16 Ansichten (letzte 30 Tage)
Berk Opla
Berk Opla am 12 Jul. 2021
Beantwortet: Walter Roberson am 12 Jul. 2021
function y = mypnz(x)
% negative positive zero
[m,n] = size(x);
pp = 0;
nn = 0;
zz = 0;
for a = 1:m
for b = 1:n
if x (a,b) < 0
nn= nn+1 ;
end %if
if x (a,b) > 0
pp= pp+1 ;
end %if
if x (a,b) == 0
zz = zz+1 ;
end %if
end % for-xb
end % for-a
y= [pp nn zz];
i'm very new to matlab but how do i get the size (x) line to work? i t works when i run it in the command window

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Jul. 2021
You cannot run that code by pressing the green Run button. When you press the green Run button then the function is executed with no arguments. You need to go down to the command line and run the function with an argument.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by