채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 3월 18일

0 개 추천

Hi Eliane,
Here is the code that does it
t = -1:0.01:1; % Set the limits of span
x = zeros(length(t),1); % Initialize an array with zeros
t1 = t>=-0.5 & t<0.5; % Find the indices between -0.5 and 0.5
x(t1) = cos(3*pi*t(t1)); % Assign those indices with cosine function
plot(t,x) % Plot the figure
Hope this helps.
Regards,
Sriram

댓글 수: 2

Eliane van Hoef
Eliane van Hoef 2020년 3월 18일
Thank you, this was indeed were I was looking for!
Sriram Tadavarty
Sriram Tadavarty 2020년 3월 18일
Do accept the answer if helpful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by