I want to plot audio files in Vertically

4 次查看(过去 30 天)
i want to plot audio files in vertically...please refer the attachment.....please help me to solve this...

采纳的回答

Star Strider
Star Strider 2021-10-27
See if the strips function will produce the desired result.
.
  9 个评论
Star Strider
Star Strider 2021-11-3
As I wrote previously —
What is wrong with it?
I cannot run it to test it.
If it throws an error, please copy and paste all the red text from the Command Window to a Comment here.
If it does not throw an error, please describe what it is doing that it should not do, or what it is not doing that it should do, and the part of the code that is causing those problems.
The code is too long and too complicated for me to read it and determine if there are any problems (I might miss them because my experience with App Designer is extremely limited since I have no reason to build Apps), and I cannot run it to test it because I do not have access to your computer, where the files that it works with are located.
I will be glad to help as much as I can, however I need to know what the problem is with the code.
.

请先登录,再进行评论。

更多回答(1 个)

Deepu S S
Deepu S S 2021-11-9
function C_Test_Callback(hObject, eventdata, handles)
% hObject handle to C_Test (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('entered')
disp(' Test run')
disp('Entered');
workspace; % Make sure the workspace panel is showing.
fontSize = 13;
% Specify the folder where the files live (unless a valid folder is hard coded in).
CHDFolder = '-'; %'D:\My Music\My Albums\Led Zeppelin\Early Days- The Best of Led Zeppelin, Vol. 1'; % Most awesome rock band of all time.
% Check to make sure that folder actually exists. Tell user to pick a folder if the folder doesn't exist.
disp('Entered');
if ~isfolder(CHDFolder)
promptMessage = sprintf('On the next window, please specify your folder of CHD Audio files.');
titleBarCaption = 'Folder?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
return;
end
CHDFolder = uigetdir(CHDFolder);
if CHDFolder == 0
% User clicked Cancel.
return;
end
end
% Create a figure for the plots with the folder name at the top middle.
hFig = figure;
% c =uicontrol(VerticalAlignment);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.1, 1, 0.9]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
% vAlignObj = VAlign()
set(gcf, 'Name', 'This program was written by DEEPU', 'NumberTitle', 'Off')
textLabel = uicontrol('Style','text', 'Units', 'normalized', 'Position', [0, 0.95, 1, 0.05], 'FontSize', 16, ...
'String', CHDFolder, 'verticalalignment', 'center');
% Get a list of all files in the folder with the desired file name pattern.
% First define the extension you want to use.
extension = '*.mp3','*.wav';
filePattern = fullfile(CHDFolder, extension); % Change to whatever pattern you need.
theFiles = dir(filePattern);
% Bail out, with an error message, if there are no music files in that folder.
numberOfFiles = length(theFiles);
if numberOfFiles == 0
errorMessage = sprintf('Error: No %s CHD Audo files were found in folder:\n%s', extension, CHDFolder);
uiwait(errordlg(errorMessage));
close(hFig);
return;
end
% Now loop over all files, reading them in and plotting their audio waveforms.
rows = ceil(sqrt(numberOfFiles));
fprintf(1,'please wait', 'Now reading from folder %s\n', CHDFolder);
for k = 1 : numberOfFiles
% Get the filename of the audio waveforms.
baseFileName = theFiles(k).name;
fullFileName = fullfile(CHDFolder, baseFileName);
fprintf(1, ' Now reading "%s"\n','please wait', baseFileName);
% Read the audio waveforms.
[y, fs] = audioread(fullFileName);
%------------------------------------------------------------------------------
% Plot the waveform.
subplot(rows, rows, k);
tDouble = (1 : length(y)) / fs; % Get time axis as a double. Convert number of elements into actual seconds (still a double though).
tDouble = tDouble / 60; % Convert to minutes (still a double though).
tMin = datetime(0,0,0) + minutes(tDouble); % Convert variable class from "double" to "duration".
plot(tMin, y(:, 1)); % Display waveform.
%------------------------------------------------------------------------------
% Make the plot fancy.
% Make the time axis show up in mm:ss format
ax = gca;
% xt = datetime(0,0,0) + minutes(0 : 0.5 : max(tDouble)); % Tick marks every 30 seconds.
xt = datetime(0,0,0) + minutes(0 : 1 : max(tDouble)); % Tick marks every 1 minute.
xticks(xt);
xtickformat('m:ss');
ax.XTickLabel = ax.XTickLabel;
xlabel('Time');
grid on;
title(baseFileName, 'FontSize', fontSize);
% Have it end on the last element, not necessarily on minute boundaries.
xlim([datetime(0,0,0), tMin(end)]);
ylim([-1, 1]);
drawnow; % Force display to update immediately.
end
entered
Test run
Entered
Entered
Error using uicontrol
There is no verticalalignment property on the UIControl class.
Error in EEG_SCT>C_Test_Callback (line 10603)
textLabel = uicontrol('Style','text', 'Units', 'normalized', 'Position', [0, 0.95, 1, 0.05], 'FontSize', 16, ...
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in EEG_SCT (line 37)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)EEG_SCT('C_Test_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating Menu Callback.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by