How do I compare chords played on a guitar with a known sample? I want to create a project that will recognized the chords that i played in guitar.
I recorded a raw sound to be compare to the one that the user will input.

Example

I have a recorded sound chordA then I will ask the user to play a sound in the guitar and check if the signal is similar to my sound chordA..

Getting the audio signal is easy but comparing them is so hard. What is the method that will suit my application? 

This is my code: 

recObj = audiorecorder; 
disp('Start speaking.') 
recordblocking(recObj, 4); 
disp('End of Recording.'); 
myRecording = getaudiodata(recObj); 
wavwrite(myRecording,'chordread.wav'); 
[x, Fs] = wavread('chordread.wav'); 
[x1, Fs1] = wavread('chordA.wav'); 
Y = fft(x); 
Z = fft(x1); 


Now that I have Y and Z how can I compare those two?
You probably need more than one algorithm for an accurate detection. Work on frequency domain (mostly via DFT and spectrogram) is the most often used initial transform. After that sophisticated probabilistic models originally used in speech recognition are applied, such as hidden Markov models, dynamic Bayesian networks, and conditional random fields.

The review article Automatic Chord Transcription Using Computational Models of Musical Context gives you a thorough overview on the relevant technique, although it focuses on a more complicated chords recognition with more than one instrument (key, bass note, beat are all considered as well). 

There are also some open source chord detection algorithms:
Chordino, Chordata, and
LabROSA Chord Recognition. Note that in LabROSA, a supervised learning method is applied to "teach" the model recognize the chords with higher accuracy. 

This is a very interesting topic, and I look forward to see your update in your guitar chord detection result.