You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
modulating the meesage signal
1 view (last 30 days)
Show older comments
yofiandi yosmansyah
on 10 Jan 2013
hi guys i have a question which is how to write the matlab code for a messages signal
m(t) =
1 when 0=<t=<0.05
-9 when 0.05=<t=<0.1
else is 0
pls help me and thanks
15 Comments
Walter Roberson
on 10 Jan 2013
You did not ask a question ?
yofiandi yosmansyah
on 10 Jan 2013
what i mean is what is the matlab code to create that message signal m(t)..thanks
Walter Roberson
on 10 Jan 2013
You do not define m(t) for t <= 0 or t >= 0.1 ?
yofiandi yosmansyah
on 10 Jan 2013
oh ya, the m(t) for t<0 and t>0.1 is equal to 0
Amith Kamath
on 10 Jan 2013
I suppose you mean:
t = 0:10e-5:0.1; %use your own step size.
m = ones(size(t));
m(t >= 0.05) = -9;
plot(t,m)
but it would definitely help if you are clearer about what you want to modulate, and what 'message' is?
yofiandi yosmansyah
on 10 Jan 2013
Edited: yofiandi yosmansyah
on 10 Jan 2013
so i had given the carrier c(t)=cos(2pi*fc*t) and the message signal m(t)={1, for 0=<t=<0.05 and -9, for 0.05=<t=<0.5 and 0 for elsewhere} then i need to plot the m(t) signal, the c(t) and the modulated signal s(t). so far i only can answer to plot the c(t) signal which i found the matlab code to be like :
ac = 1; fs = 5000;
t = 0: 1/fs :0.03;
fc = 200;
ct =ac*cos(2*pi*fc*t);
% Plot the carrier signal
figure(1);
plot(t,ct);
xlabel('Time (sec)');
ylabel('Amplitude');
title(['Carrier Signal with frequency = ',num2str(fc),' Hz']);
grid on;
now i cant proceed to the next stage which are plotting m(t) still havent got one and s(t)the modulated signal which i cant find it without the m(t)signal.
yofiandi yosmansyah
on 10 Jan 2013
so the problem i have face now is to generate the message signal m(t) which i believed it will looks like a rectangular wave with amplitude 1 and -9.. still,I cant find the matlab code. T_T
Amith Kamath
on 10 Jan 2013
So I understand you can use the same 'fs' for m(t), with t already defined. What I don't understand is how you could have one signal ranging from 0:0.03 and another from 0:0.1 and 'modulate' it. I assume you want to do m(t)*c(t), right?
yofiandi yosmansyah
on 10 Jan 2013
the first range when i put 0:1/fs:0.03 its because i want to plotting the nice cosine-wave because when i out 0:1/fs:0.1 the graph doesn't look really good. correct me if i'm wrong.. and btw i tried the m(t) that been given by you and the graph is look weird like just a horizontal line,,isnt its supposed to be a square-wave with peak to peak -9 to 1? correct me if i'm wrong again..thanks :)
Amith Kamath
on 10 Jan 2013
You must be attempting to do this:
t = -0.1:(1/5000):0.1;
m = ones(size(t));
m(abs(t) > 0.05) = -9;
figure, plot(t,m);
fc = 200;
ct = cos(2*pi*fc*t);
figure, plot(t,ct);
figure, plot(t,m.*ct);
If not, I'm not really sure I understand your question! :)
yofiandi yosmansyah
on 10 Jan 2013
m(t) still didnt generate a rectangular pulses with amplitude 1 and -9.. but really thanks for help and fast feedback..i really appreciate it :)
Walter Roberson
on 11 Jan 2013
You say "rectangular pulses", but the m(t) you define would have only one pulse.
yofiandi yosmansyah
on 11 Jan 2013
Edited: yofiandi yosmansyah
on 11 Jan 2013
oke..im sorry i was very sleep so i didnt see it clearly.. well the m(t) became 2 from t= 0 until t=0.05 and become -9from t=0.05 onward. but when t<0 and t>0.1 its supposed have a zero value. so how to make that m(t) yah? m(t) = { 1 when 0=<t=<0.05 -9 when 0.05=<t=<0.1 0 when t= elsewhere }
yofiandi yosmansyah
on 11 Jan 2013
thats it is..thanks bro for the help..i really appreciate it..btw how to plot the amplitude spectra ya??
Walter Roberson
on 11 Jan 2013
stairs() to plot.
Answers (1)
Walter Roberson
on 11 Jan 2013
Define your vector t of times. Then,
m = zeros(size(t));
m(t > 0 & t < 0.05) = 1;
m(t >= 0.05 & t <= 0.01) = -9;
Note this would be only one pulse.
See Also
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)