What am I missing here? I always get OFDMguiFnSound requires more input arguments.
3 次查看(过去 30 天)
显示 更早的评论
function OFDMguiFnSound(action)
% Consolidates all of the GUI callbacks into one main function
stringArray = [...
% Slide 1
'Welcome to the Sound OFDM demo. This simulates QAM '...
'and OFDM using a sound file as input to demonstrate '...
'the advantages of using OFDM with a multipath '...
'channel. '...
'Choose the strength of multipath present in the '...
'channel and the plot will show the current channels '...
'frequency response. ';...
% Slide 2
'Here is a frequency domain (FD) representation of the '...
'QAM data to be transmitted. '...
'Press any key to continue. '...
' '...
' '...
' '...
' ';...
% Slide 2b
'For QAM (single-carrier) transmission, this plot '...
'shows the channel frequency response (black) and the '...
'received data (light blue) overlayed on the original '...
'data (blue). Note that the received data is slightly '...
'distorted due to the fading channel caused by '...
'multipath. '...
'Press any key to continue. ';...
% Slide 2c
'Here is a frequency domain (FD) representation of the '...
'OFDM data to be transmitted. '...
'Press any key to continue. '...
' '...
' '...
' '...
' ';...
% Slide 2d
'For OFDM (multi-carrier) transmission, this plot '...
'shows the channel (black) and received data (light '...
'blue) overlayed on the original data (blue). Note '...
'that the OFDM received data also exhibits multipath '...
'distortion. Also, notice that the OFDM signal is '...
'spread out over more bandwidth than QAM since OFDM '...
'uses many carrier frequencies. ';...
% Slide 3
'Here are the final plots of the recovered sound files '...
'along with the Bit Error Rate (BER) for OFDM and QAM. '...
'Click any of the 3 buttons to hear these sounds. '...
'Since OFDM handles multipath better, the sound is '...
'less distorted. '...
'The Long Sounds demonstrate longer examples that have '...
'already been processed offline. '];
switch action
case 'next' %---------------------------------------
textHnd1=findobj('Tag','StaticTextFeedback');
nextHnd1=findobj('Tag','PushbuttonNext'); % handler for the Next button
% axis handlers
axisHnd1=findobj('Tag','Axes1'); % main
axisHnd2=findobj('Tag','AxesOriginal'); % original
axisHnd3=findobj('Tag','AxesQAM'); % QAM
axisHnd4=findobj('Tag','AxesOFDM'); % OFDM
% multipath handlers
textHnd2=findobj('Tag','StaticTextMultipath');
popupHnd1=findobj('Tag','PopupMenuMultipath');
% Generated Sounds handlers
textHnd3=findobj('Tag','StaticTextGenSounds');
OriginalHnd1=findobj('Tag','PushbuttonOriginal');
QAMHnd1=findobj('Tag','PushbuttonQAM');
OFDMHnd1=findobj('Tag','PushbuttonOFDM');
% Long Sounds handlers
textHnd4=findobj('Tag','StaticTextLongSounds');
OriginalLongHnd1=findobj('Tag','PushbuttonOriginalLong');
QAMLongHnd1=findobj('Tag','PushbuttonQAMLong');
OFDMLongHnd1=findobj('Tag','PushbuttonOFDMLong');
% BER handlers
textHnd5=findobj('Tag','StaticTextBER1'); % label
textHnd6=findobj('Tag','StaticTextBER2'); % label
textHnd7=findobj('Tag','StaticTextBERQAM'); % OFDM BER field
textHnd8=findobj('Tag','StaticTextBEROFDM'); % QAM BER field
global COUNTER
if isempty(COUNTER)
COUNTER = 0; % initialize COUNTER if doesn't exist
end
COUNTER = COUNTER + 1;
[r , ~]=size(stringArray);
if COUNTER > r
COUNTER = 0;
close(gcf)
% SoundGUI
SoundGUI_win % windows only
else
set(textHnd1,'String',stringArray(COUNTER,:))
switch(COUNTER)
case 1
% disp('Slide 1')
% Show/Hide the GUI
set(nextHnd1,'String','Next')
% show multipath controls
set(textHnd2,'Visible','on')
set(popupHnd1,'Visible','on')
% enable multipath controls
set(textHnd2,'Enable','on')
set(popupHnd1,'Enable','on')
% show main axis
set(axisHnd1,'Visible','on'),axes(axisHnd1)
% hide other axis's
set(axisHnd2,'Visible','off')
set(axisHnd3,'Visible','off')
set(axisHnd4,'Visible','off')
% hide generated sounds stuff
set(textHnd3,'Visible','off')
set(OriginalHnd1,'Visible','off')
set(QAMHnd1,'Visible','off')
set(OFDMHnd1,'Visible','off')
% hide long sounds stuff
set(textHnd4,'Visible','off')
set(OriginalLongHnd1,'Visible','off')
set(QAMLongHnd1,'Visible','off')
set(OFDMLongHnd1,'Visible','off')
% hide the BER displays
set(textHnd5,'Visible','off')
set(textHnd6,'Visible','off')
set(textHnd7,'Visible','off')
set(textHnd8,'Visible','off')
set(popupHnd1,'Value',1) % no channel by default
% default plot
plot(0:.05:.5,zeros(1,11)),axis([0 0.5 -12 6]),title('Channel Magnitude Response')
xlabel('Digital Frequency'),ylabel('Magnitude (dB)')
case {2, 3, 4, 5}
% disp('Slide 2')
% disble multipath controls
set(textHnd2,'Enable','off')
set(popupHnd1,'Enable','off')
setupSoundGUI % sets up the Sound GUI variables
set(textHnd1,'String','QAM Simulation... Please Wait')
QAM
set(textHnd1,'String',stringArray(COUNTER,:))
fft_temp = abs(fft(QAM_tx_data));
fft_temp = fft_temp(1:floor(0.5*length(fft_temp))); % truncate (+ spectrum)
dig_x_axis = (1:length(fft_temp)) / (2*length(fft_temp));
plot(dig_x_axis, fft_temp)
title('FFT of Transmitted QAM')
% calculate the BER and store for slide 6
global BER_QAM_TEMP;
binary_err_bits_QAM = 0;
for i = 1:length(data_in)
err = abs(data_in(i)-QAM_data_out(i));
if err > 0
binary_err_bits_QAM = binary_err_bits_QAM + 1;
end
end
BER_QAM_TEMP = 100 * binary_err_bits_QAM/data_length;
COUNTER = COUNTER + 1;
pause
% disp('Slide 2b')
set(textHnd1,'String',stringArray(COUNTER,:))
hold on
% QAM Plotting
fft_temp = abs(fft(QAM_rx_data));
fft_temp = fft_temp(1:floor(0.5*length(fft_temp))); % truncate
plot(dig_x_axis, fft_temp,'c'),title(' ')
% channel display
if channel_on == 1
ComputeChannelGUI
size_mag=max(mag)-min(mag); % for scaled channel plot
plot(W/(2*pi),(0.5*max(fft_temp)/size_mag)*(mag + abs(min(mag))) + 0.5*max(fft_temp),'k')
end
hold off
COUNTER = COUNTER + 1;
pause
% disp('Slide 2c')
set(textHnd1,'String','OFDM Simulation... Please Wait')
OFDM
set(textHnd1,'String',stringArray(COUNTER,:))
fft_temp = abs(fft(xmit));
fft_temp = fft_temp(1:floor(0.5*length(fft_temp))); % truncate
dig_x_axis = (1:length(fft_temp)) / (2*length(fft_temp));
plot(dig_x_axis, fft_temp)
title('FFT of Transmitted OFDM')
% calculate the BER and store for slide 6
global BER_OFDM_TEMP;
binary_err_bits_OFDM = 0;
for i = 1:length(data_in)
err = abs(data_in(i)-output(i));
if err > 0
binary_err_bits_OFDM = binary_err_bits_OFDM +1;
end
end
BER_OFDM_TEMP = 100 * binary_err_bits_OFDM/data_length;
COUNTER = COUNTER + 1;
pause
% disp('Slide 2d')
set(textHnd1,'String',stringArray(COUNTER,:))
hold on
% OFDM Plotting
fft_temp = abs(fft(recv));
fft_temp = fft_temp(1:floor(0.5*length(fft_temp))); % truncate
plot(dig_x_axis, fft_temp,'c'),title(' ')
% channel display
if channel_on == 1
plot(W/(2*pi),(0.5*max(fft_temp)/size_mag)*(mag + abs(min(mag))) + 0.5*max(fft_temp),'k')
end
hold off
case 6
% disp('Slide 3')
setupSoundGUI
% hide main axis
plot(0) % clear the plot
axis off
% set(axisHnd1,'Visible','off')
% show other axis's
set(axisHnd2,'Visible','on')
set(axisHnd3,'Visible','on')
set(axisHnd4,'Visible','on')
% hide multipath controls
set(textHnd2,'Visible','off')
set(popupHnd1,'Visible','off')
% show generated sound buttons
set(textHnd3,'Visible','on')
set(OriginalHnd1,'Visible','on')
set(QAMHnd1,'Visible','on')
set(OFDMHnd1,'Visible','on')
% show long sounds stuff
set(textHnd4,'Visible','on')
set(OriginalLongHnd1,'Visible','on')
set(QAMLongHnd1,'Visible','on')
set(OFDMLongHnd1,'Visible','on')
% show the BER displays
set(textHnd5,'Visible','on')
set(textHnd6,'Visible','on')
set(textHnd7,'Visible','on') % QAM
set(textHnd8,'Visible','on') % OFDM
% Display the BERs
global BER_QAM_TEMP;
global BER_OFDM_TEMP;
set(textHnd7,'String',strcat(num2str(BER_QAM_TEMP,3),' %'))
set(textHnd8,'String',strcat(num2str(BER_OFDM_TEMP,3),' %'))
clear global BER_QAM_TEMP; % clean up the globals
clear global BER_OFDM_TEMP;
% Plot the Sounds
% Note: axes(handle) sets to plot on the handle axis
axes(axisHnd2)
plot(wavread(file_name)),title('Original sound')
axes(axisHnd3)
plot(wavread('QAM_out.wav')),title('QAM sound')
axes(axisHnd4)
plot(wavread('OFDM_out.wav')),title('OFDM sound')
set(nextHnd1,'String','Start Over') % repeat if desired
otherwise
disp('error')
COUNTER = 0;
end
end
case 'mp_channel' %-----------------------------------
ComputeChannelGUI
if noChannel ~= 1
% large or small case
plot(W/(2*pi),mag),axis([0 0.5 -12 6]),title('Channel Magnitude Response')
xlabel('Digital Frequency'),ylabel('Magnitude (dB)')
else
% none case
plot(0:.05:.5,zeros(1,11)),axis([0 0.5 -12 6]),title('Channel Magnitude Response')
xlabel('Digital Frequency'),ylabel('Magnitude (dB)')
end
case 'close' %---------------------------------------
clear global COUNTER
close(gcbf)
case 'PlayOriginal' %-----------------------------------
sound(wavread('shortest.wav'),11025)
case 'PlayQAM' %---------------------------------------
sound(wavread('QAM_out.wav'),11025)
case 'PlayOFDM' %---------------------------------------
sound(wavread('OFDM_out.wav'),11025)
case 'PlayOriginalLong' %-----------------------------------
sound(wavread('Long.wav'),11025)
case 'PlayQAMLong' %---------------------------------------
sound(wavread('QAM_Long.wav'),11025)
case 'PlayOFDMLong' %---------------------------------------
sound(wavread('OFDM_Long.wav'),11025)
case 'figure' %---------------------------------------
% this is called whenever the figure is first created -or NOT???
% textHnd1=findobj('Tag','StaticTextFeedback');
% axisHnd1=findobj('Tag','Axes1');
% set(textHnd1,'String','Sound OFDM Demo') % default text message
% set(axisHnd1,'Visible','off') % hide Axis to begin
end
0 个评论
回答(1 个)
Sahithi Kanumarlapudi
2020-11-19
Hi,
You might have defined another function with the same name but with different number of inputs. Ensuring that the required 'OFDMguiFnSound' is on the path might help you.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Test and Measurement 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!