How do I create a square wave using 'zeros' and 'ones' functions?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Here is my code so far.
clear all; close all; clc;
incrm = 0.01;
T0 = 2;
W0 = pi;
t = 0:0.01:10;
xt = ???????????????
plot(t,xt)
hold on
xlim([0,10]);
ylim([0,1]);
xlabel('t');
ylabel('xt');
title('Signal Approximation')
채택된 답변
madhan ravi
2018년 10월 27일
편집: madhan ravi
2018년 10월 27일
Edited
t = 0:0.01:10;
x=ones(1,numel(t)) %add this
x(t>=1 & t<2 | t>=3 & t<4 | t>=5 & t<=6 | t>=7 & t<=8 | t>=9 & t<=10 )=0 %and this
plot(t,x) % if you add t+pi horizontal shift or t-pi
xlim([0,10]);
ylim([0,1]);
xlabel('t');
ylabel('xt');
title('Signal Approximation')
댓글 수: 20
use builtin square() to create square wave
I have to do it using 'zeros' and 'ones' functions!
homework?
Yes it is for a lab.
see the edited answer
That didn't work. It gave me all zeros in my plot. (The second image I sent.) I need it to look like the first image I sent.
madhan ravi
2018년 10월 27일
편집: madhan ravi
2018년 10월 27일
See the edited answer and attached screenshot now
Yes. I am trying it now
if its what you want accept the answer so people know question is solved
upload the code you are trying
dude ! change
x(t>=1 & t<2 | t>=3 & t<4 | t>=5 & t<=6 | t>=7 & t<=8 | t>=9 & t<=10 )=0
to this
xt(t>=1 & t<2 | t>=3 & t<4 | t>=5 & t<=6 | t>=7 & t<=8 | t>=9 & t<=10 )=0
I noticed that and changed it and it still isn't working.
x(t>=1 & t<2 | t>=3 & t<4 | t>=5 & t<=6 | t>=7 & t<=8 | t>=9 & t<=10 )=0 <----- it should be zero not one!!!
YES!!! It's working now! Thank you
madhan ravi
2018년 10월 27일
편집: madhan ravi
2018년 10월 27일
Anytime ,if it works accept the answer
Is there a way to do it with a combination of the zeros and ones functions?
not that I'm aware of
Alright thanks again.
Anytime
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
제품
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
