How do I solve Check for incorrect argument data type or missing argument in call to function 'exp' MATLAB
Show older comments
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)
The command
sym 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
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
The exp function is not defined for fi objects.
which -all exp(x)
Compare to a sym object, which does have an exp method defined.
z = sym('z');
which -all exp(z)
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)
y2 = exp(x)
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');
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!