y(t)=A1cos(200*pi*t)+A2sin(200*pi*t)
13 views (last 30 days)
Show older comments
How can i type this equation into matlab using funtion?
How can i plot the output of vector y?
1 Comment
Walter Roberson
on 26 Oct 2012
Please use better tags for your Question; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
Answers (2)
Wayne King
on 26 Oct 2012
Edited: Wayne King
on 26 Oct 2012
Hi, Welcome to MATLAB! May I suggest you spend some time reading the Getting Started Guide or some of the excellent online tutorials for MATLAB.
t = 0:0.001:1;
A1 = 1;
A2 = 1;
y = A1*cos(2*pi*100*t)+A2*sin(2*pi*100*t);
plot(t,y)
0 Comments
Matt Fig
on 26 Oct 2012
Edited: Matt Fig
on 26 Oct 2012
A1 = 3;
A2 = 5;
t = 0:1/(2*200*pi):pi/8;
y = A1*cos(200*pi*t)+A2*sin(200*pi*t);
plot(t,y)
If you want to use an M-File function, define it like this:
function y = myfunc(t,A1,A2)
y = A1*cos(200*pi*t)+A2*sin(200*pi*t);
Then from the command line, call it like this:
A1 = 3;
A2 = 5;
t = 0:1/(2*200*pi):pi/8;
y = myfunc(t,A1,A2);
plot(t,y)
0 Comments
See Also
Categories
Find more on Startup and Shutdown 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!