How do I solve Check for incorrect argument data type or missing argument in call to function 'exp' MATLAB

6 views (last 30 days)
M=4;
a= log2(M);
g = (sin(pi/M))^2;
SNRdB=0:2:10;
for ii=1:size(SNRdB,2);
EbNodB = SNRdB(ii);
end
for jj=1:length(SNRdB)
SNR(jj)=10^(EbNodB./10);
end
z = SNR(ii);
sym fi
fx=exp((1+(g.*z.*a./((sin(fi))^2))));
y=int(fx,0,((M-1)*pi)/M);

Answers (1)

Steven Lord
Steven Lord on 19 Jun 2022
The command
sym fi
ans = 
fi
does not create a symbolic variable named fi in the workspace. You can see this by asking what variables are in the workspace:
whos
Name Size Bytes Class Attributes ans 1x1 8 sym cmdout 1x33 66 char
So when you use fi on the next line it calls the fi function with 0 inputs and attempts to call exp on that fixed-point variable.
x = fi
x = [] DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 15
The exp function is not defined for fi objects.
which -all exp(x)
'exp(x)' not found.
Compare to a sym object, which does have an exp method defined.
z = sym('z');
which -all exp(z)
/MATLAB/toolbox/symbolic/symbolic/@sym/exp.m % sym method
So exp(z) will work (and call the sym method) while exp(x) will not (it will call neither the sym method nor the built-in function.)
y1 = exp(z)
y1 = 
y2 = exp(x)
Check for incorrect argument data type or missing argument in call to function 'exp'.
When you call sym in your function to define fi, I recommend always calling it in function form with an output argument like I did to define z.
fi = sym('fi');

Tags

Community Treasure Hunt

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

Start Hunting!