Matlab ASK PSK FSK Code for Square and Sine Waves | Step-by-Step Guide

  • MATLAB
  • Thread starter sara_UK
  • Start date
  • Tags
    Matlab
In summary, the conversation is about someone trying to write code for ASK in Matlab and not getting the desired output. They have shared their code and are seeking help to correct it. One person suggests checking the calculation for ASK, while another suggests following a blog for code assistance.
  • #1
sara_UK
4
0
Hello guys..

I am trying to write a code for ASK in Matlab, but it doesn't give me the final figure!

% Generating a input square wave
x1 = 0:(pi/100):(10*pi);
y1 = square(x1);
A = plot(x1,y1);
figure(1),A,title( 'Square wave');xlabel('x'); ylabel('y');ylim([0,1]);grid;

% Generating a carrier(cosine wave) with a higher frequency as compared to sq.wave
f=0.8
t = 0:(pi/100):(10*pi);
y2 = cos(2*pi*f*t);
figure(2),B = plot(t,y2),title( 'Sine wave');xlabel('x'); ylabel('y');ylim([-2,2]); xlim([0,35]);grid;

ASK = A.^B;
figure(3),plot(t,ASK),title('ASK');xlabel('x'); ylabel('y');ylim([-2,2]); xlim([0,35]);grid;

your helpd would be very much appriciated .

Thanks
 
Physics news on Phys.org
  • #2
Your calculation of ASK is not correct and so you are not getting the plot. Please check.
 
  • #3
Which calculation do u mean? and how do u suggest me correcting it?
 
  • #4
you can fallow this blog to get code
kemppro.blogspot.in
 
  • #5
for sharing your code with us. It seems like you are on the right track, but there are a few things that need to be addressed in order to get the desired output.

Firstly, in your ASK code, you are using the operator "^" which is used for exponentiation, but for ASK modulation, the carrier wave needs to be multiplied with the binary input signal. So instead of "A.^B", you should use "A.*B" to get the correct result.

Secondly, the frequency of the carrier wave should be much higher than the frequency of the input signal. In your code, you have set the frequency of the carrier wave to be 0.8, which is quite low. I would suggest using a frequency of at least 10 times higher than the input signal frequency.

Lastly, in order to see the final figure, you need to add the command "hold on" before the plot command in figure 3. This will ensure that all the plots are shown on the same figure.

I hope this helps and you are able to get the desired output. If you continue to face any issues, please feel free to reach out for further assistance. Keep up the good work!
 

What is Matlab ASK PSK FSK Code for Square and Sine Waves?

Matlab ASK PSK FSK Code is a programming code used to generate square and sine waves for Amplitude Shift Keying (ASK), Phase Shift Keying (PSK), and Frequency Shift Keying (FSK) modulation techniques. It allows for the simulation and analysis of these modulation techniques in Matlab.

Why is this code important in the field of communication?

This code is important in communication because it allows for the analysis and simulation of different modulation techniques, which are essential for transmitting and receiving data in communication systems. It helps in understanding the performance of different modulation techniques and their impact on the quality of communication signals.

What are the steps involved in using this code?

The steps involved in using this code include defining the parameters of the signal such as carrier frequency and modulation index, generating the carrier signal, generating the modulating signal, performing the modulation using the desired technique, and plotting the modulated signal in the time and frequency domains.

How accurate are the results obtained from this code?

The accuracy of the results obtained from this code depends on the accuracy of the input parameters and the simulation settings. If the parameters are defined accurately and the simulation settings are appropriate, the results obtained can be highly accurate and reliable for analysis and comparison of different modulation techniques.

Can this code be used for educational purposes?

Yes, this code can be used for educational purposes to understand the concepts of modulation techniques and their implementation in Matlab. It can also be used by students and researchers for simulation and analysis of communication systems in their projects and studies.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
126
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
Back
Top