Change time scale of a discrete function by a factor?

6 ビュー (過去 30 日間)
Himanshu Sharma
Himanshu Sharma 2018 年 11 月 4 日
回答済み: Prakhar Jain 2018 年 11 月 14 日
%if
% input sequence
bits = [1,0,1,1,0,0,0,1];
% Mapping
for a=1:length(bits)
if bits(a) == 1
bit(a) = 5;
else
bit(a) = -5;
end
end
i = 1;
t = 0:0.01:length(bits);
for b=1:length(t)
if t(b) <= i
y(b) = bit(i);
else
y(b) = bit(i);
i = i+1;
end
end
plot(t,y);
I am trying to change the length of 1 bit from 1s to 1us which will change step from 0.01 to 1e-8 but it gives me an error and if I just plot it on 0 to 8e-6 without proper implementation it will only print the first value which is between 0 and 1. Any ideas on how to plot an array of length 8 on timescale 0 to 8e-8??

回答 (1 件)

Prakhar Jain
Prakhar Jain 2018 年 11 月 14 日
Hi Himanshu,
Your code look correct and even works for me without an error.
The plot is as shown below:
Plot.PNG
Also, the workspace variables are of proper size as you can see in below figure size of t and y:
Workspace-Variables.PNG

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by