please the 'for' loop in the following program
Mostrar comentarios más antiguos
clear;
clc;
b = input('Enter the Bit stream \n ');
%b = [0 1 0 1 1 1 0];
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b_p(i);
end
end
bw = bw(100:end);
sint = sin(2*pi*t);
st = bw.*sint;
subplot(3,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(3,1,2)
plot(t,sint)
grid on ; axis([0 n -2 +2])
subplot(3,1,3)
plot(t,st)
grid on ; axis([0 n -2 +2])
7 comentarios
Paulo Silva
el 21 de Jul. de 2011
please the fix your code and please the explain what you want :)
PS: This time I'm written with broken English on purpose
Jan
el 21 de Jul. de 2011
@Paulo: Why this broken is? Please do not confuse me German speaker.
Jan
el 21 de Jul. de 2011
@Krishna: Please format your code by editing your original message (see the "{} Code" button) and ask a question. It is not clear if there is a problem at all, and if so, which FOR loop could be meant.
Sean de Wolski
el 21 de Jul. de 2011
@Jan: never end a sentence with "is" "was" "were" "as" "like" since they have to modify something.
Correction: "why is this broken? Please do not confuse me {'as a', 'the', 'this'} German speaker." Since you need to correlate "German speaker" to "me."
Sean de Wolski
el 21 de Jul. de 2011
@Paulo, can you edit posts/how does that work?
Walter Roberson
el 21 de Jul. de 2011
Paulo has reached a reputation level sufficient to have been invited to be a MATLAB Answers Community Editor; I do not, though, know whether the configuration change needed for him to actually edit has gone through yet.
The Community Editors have access to the normal "edit" button on all Answers, and can delete any Comment or Answer or even Question; the buttons for doing that are simply the normal buttons that the original poster would have.
Paulo Silva
el 21 de Jul. de 2011
Walter and Sean my editor status is still waiting to be implemented but I really don't have time do be here editing messages (have just a month to finish my thesis), my main reason to be here is just to learn and try to help others.
Respuestas (1)
Sean de Wolski
el 21 de Jul. de 2011
b_p = ones(size(b));
b_p(~b) = -1;
bw = [kron(b_p,ones(1,100)) b_p(end)];
creates the same thing you have for b_p, bw...
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!