1

So i Created an .m file that has a sawtooth signal wave that i am trying to modulate. I have no Problem producing the wave form but when i try to take the .m file and multiply it by "c" MATLAB returns the original waveform. This specific program is using the Double Side Band Modulation Technique. The first piece is my waveform.

function y = Signal
% Signal Summary of this function goes here
n = 23; % Number of Harmonics
t = 0:.0002:n; % incremental value
y = sawtooth(t,.2); % Wave creation
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time');
title('Sawtooth Wave');

end

This next piece is where i am trying to call the .m file, multiply it by 'c' and plot the resulting function.

function [ DSBModulation ] = DSB( DSBModulation )
% Program for DSB-AM

n = 23; 
fc = 100;
t = 0:.0002:n;
sig = Signal; % this is how im trying to call the .m file so i can manipulate it

c = cos((2*pi*fc*t)); % using this as the modulating function
u(sig) = (sawtooth(t,.2)).*c; % Multiplying the signal
plot(t,u(sig)); %Displaying the Signal

end 
Zanderg
  • 159
  • 2
  • 5
  • 11

1 Answers1

0

The result of the signal generation is stored in the variable sig on the following line of the DSB function:

sig = Signal;

Further operation to modulate the generated signal should thus make use of that sig variable instead of trying to use the local sawtooth variable defined in the scope of Signal. Then you should also note that the notation u(sig) in Matlab represents a vector u which is indexed by the values in sig, rather than the mathematical notion of a function u of the variable sig.

So to compute your modulated signal vector you would thus use:

u = sig.*c; % Multiplying the signal 

Finally, to plot the results on the same figure you could use the hold command, or otherwise use separate figure (otherwise your second plot command will erase the graph of the first plot):

close all;
plot(t,u); %Displaying the Signal
hold on; plot(t,sig,'r','LineWidth',3); % Overlay the unmodulated signal for reference

ylabel ('Amplitude');
xlabel ('Time');

Which should give you the following result:

enter image description here

SleuthEye
  • 14,379
  • 2
  • 32
  • 61