how to plot x(t) = 0.9^k*cos(pi*k/5)*u(k) with simulink

3 ビュー (過去 30 日間)
Samuel
Samuel 2011 年 6 月 25 日
I tried to plot x(t) = 0.9^k*cos(pi*k/5)*u(k) with simulink.
I used constant, sine wave, Pulse generator and product block in order to express 0.9, cos(pi/5), and u(t). But I couldn't figure out how to express 0.9^k.
Please help...

採用された回答

Paulo Silva
Paulo Silva 2011 年 6 月 25 日
Something is wrong with that equation, can you see the error?
here's the MATLAB code, I leave the simulink for you to do, it's easy after knowing the basics.
k=1:100; %samples
u(k)=ones(1,numel(k)); %the input is a discrete step
x(k) = 0.9.^k.*cos(pi*k/5).*u(k);
plot(k,x(k))
hold on
plot(k,u(k),'r')
axis([0 numel(k) -2 2])
legend('x(k)=0.9^k*cos(pi*k/5)*u(k)','u(k)')
I couldn't wait so I just tested it on simulink, never done something similar before so I improvised, the results are similar to those of the script.
First thing you should do is change the configuration parameters.
Start time -> 1 Stop time -> 100 Solver Type -> Fixed step Sample time -> 1
Now the blocks
Clock -> Fcn -> Scope
In the Fcn put the expression -> 0.9^u*cos(pi*u/5)
Do the simulation
PS: Don't blame me if there's something wrong, try it and check if all is correct.
  3 件のコメント
Paulo Silva
Paulo Silva 2011 年 6 月 25 日
x(t) should be x(k) or something similar
Samuel
Samuel 2011 年 6 月 26 日
It was typo. It is x(k).
I plot this eq. with code below
anyway, I will try again..Thanks.
m = 10;
k = -m:m;
x = (0.8).^k.*cos((pi*k)./5).*(k>=0);
subplot(2,1,1);
stem(k,x); grid on;
axis([-m,m,-1,1]);
set(gca,'XTick',-m:m);
set(gca,'XTicklabel',-m:m);
set(gca,'YTick',-1:1);
set(gca,'YTicklabel',-1:1);
title('1i) x(k)=(0.8)^k*cos(pi*k/5)*u(k)');
xlabel('k');
ylabel('x(k)');

サインインしてコメントする。

その他の回答 (1 件)

Samuel
Samuel 2011 年 6 月 26 日
Thank you very much Paulo.
I successed ploting this equation based on your idea. I used ram function instead of clock as input of FCN and producted pulse with output of FCN because it is discrete squence signal.
Thanks again..!

カテゴリ

Help Center および File ExchangeSources についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by