How to create conditions according to the digital signal ?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
If i have a digital signal and if first 2 bits are 10(i have designed the pulse to have 10 as first two bits), then xp and yp should be assigned a value. The code is matching only the first bit with the digital signal it is not matching the second bit.
clc
clear all
close all
t=0:0.01:6;
fm=0.5;
pulse=(0.5).*square(2.*pi*fm.*t)+0.5;
subplot(2,1,1)
plot(t,pulse)
L=length(t)
for i=1:L
if pulse(i)==1 && pulse(i-1)==0
xp=0.402
yp=0.597
else if pulse(i)==1 && pulse(i-1)==1
xp=0.435
yp=0.290
end
end
end
0 Kommentare
Antworten (2)
Walter Roberson
am 11 Nov. 2018
You are checking backwards, looking at location i and then at the one before that.
Note you will have a problem when i is 1 as that could try to access location 1-1 = 0
2 Kommentare
Walter Roberson
am 11 Nov. 2018
t=0:0.01:6;
fm=0.5;
pulse=(0.5).*square(2.*pi*fm.*t)+0.5;
subplot(2,1,1)
plot(t,pulse)
L=length(t)
if pulse(1)==1 && pulse(2)==0
xp=0.402
yp=0.597
elseif pulse(1)==1 && pulse(2)==1
xp=0.435
yp=0.290
else
error('What did you intend xp and yp to be if the first bit is not 1?')
end
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!