How can I write this exponential function in matlab
5 views (last 30 days)
Show older comments
f(t)=0.2e^(-j(8πt-90°))+0.585e^(-j(7πt-78.69°))
0 Comments
Answers (2)
Ameer Hamza
on 27 Jun 2020
Edited: Ameer Hamza
on 27 Jun 2020
One way to write this is to create an anonymous function
f = @(t) 0.2*exp(-1i*(8*pi*t-pi/2))+0.585*exp(-1i*(7*pi*t-deg2rad(78.69)));
and then run it like this
>> f(0)
ans =
0.1147 + 0.7736i
>> f(1)
ans =
-0.1147 - 0.3736i
>> f(2)
ans =
0.1147 + 0.7736i
>> f(pi)
ans =
0.0177 + 0.3937i
Read here about anonymous function: https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html
Alternatively, create a function file named myFun.m (or whatever you want. The name of file and function must be same) and define a function like this
function y = myFun(t)
y = 0.2*exp(-1i*(8*pi*t-pi/2))+0.585*exp(-1i*(7*pi*t-deg2rad(78.69)));
end
and then you can call it like this myFun(0), myFun(pi), etc.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!