dct matlab

Download DCT Matlab

If you can't read please download the document

Upload: milericar

Post on 24-Oct-2015

56 views

Category:

Documents


6 download

DESCRIPTION

matlab, DCT, discrete fourier transform

TRANSCRIPT

DCT Syntax%%%%%%%%% START %%%%%%%clcclose allim=imread('a.bmp');im = double(im)/255;im = rgb2gray(im);subplot(211)imshow(im)title('Original image');img_dct=dct2(im);img_pow=(img_dct).^2;img_pow=img_pow(:);[B,index]=sort(img_pow);%no zig-zagB=flipud(B);index=flipud(index);compressed_dct=zeros(size(im));coeff = 20000;% maybe change the valuefor k=1:coeffcompressed_dct(index(k))=img_dct(index(k));endim_dct=idct2(compressed_dct);subplot(212)imshow(im_dct)title('DCT Compress Image');% for saving this image use "imwrite" commandimwrite(im_dct, 'compress.bmp')%%%%%%%% END %%%%%%%ASK Syntax clear all;clc;close all;F1=input('Enter the frequency of carrier=');F2=input('Enter the frequency of pulse=');A=3;%Amplitudet=0:0.001:1;x=A.*sin(2*pi*F1*t);%Carrier Sine waveu=A/2.*square(2*pi*F2*t)+(A/2);%Square wave messagev=x.*u;subplot(3,1,1);plot(t,x);xlabel('Time');ylabel('Amplitude');title('Carrier');grid on;subplot(3,1,2);plot(t,u);xlabel('Time');ylabel('Amplitude');title('Square Pulses');grid on;subplot(3,1,3);plot(t,v);xlabel('Time');ylabel('Amplitude');title('ASK Signal');grid on;ASK, FSK, PKS%matlab code for digital modulation(ask, fsk and psk)pi=3.14;f=5;f2=10;phi=pi;x=[1 0 1 1 0];nx=size(x,2);i=1;while i