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 件のコメント
madhan ravi
2018 年 10 月 27 日
use builtin square() to create square wave
I have to do it using 'zeros' and 'ones' functions!
madhan ravi
2018 年 10 月 27 日
homework?
Yes it is for a lab.
madhan ravi
2018 年 10 月 27 日
madhan ravi
2018 年 10 月 27 日
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
madhan ravi
2018 年 10 月 27 日
if its what you want accept the answer so people know question is solved
madhan ravi
2018 年 10 月 27 日
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?
madhan ravi
2018 年 10 月 27 日
not that I'm aware of
Alright thanks again.
madhan ravi
2018 年 10 月 27 日
Anytime
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
製品
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
