How to replace the wavread(file) in matlab r2015a - matlab

I am trying to run a matlab script and in the line [s, fs] = wavread(file);,
I take the following result,
Warning: WAVREAD will be removed in a future release. Use AUDIOREAD
instead. In wavread (line 62) In MEDanalysis (line 25) Error using
wavread (line 70) Invalid Wave File. Reason: Cannot open file.
Error in MEDanalysis (line 25)
[s, fs] = wavread(file);

You have 1 warning and one error:
The Warning is about using waveread which will be removed in future versions of MATLAB.
If you want your code to compatible with newer versions of MATLAB, use audioread.
The error says something about your wave file being corrupted. Can you play it in VLC for instance?

Related

Script running problem/error - Matlab 2019b

I get this error in Matlab
Attempt to execute SCRIPT feature as a function:
E:\feature.m
Error in images.internal.isFigureAvailable (line 9)
if feature('showFigureWindows')
Error in imtool (line 172)
if ~images.internal.isFigureAvailable()
Error in Untitled (line 8)
imtool close all; % Close all imtool figures.
Error in run (line 91)
evalin('caller', strcat(script, ';'));
It does not matter which code I run it always shows up. How can I solve it?
MATLAB has a built in function called feature. imtool is internally trying to call this function, but instead a script you placed on E:\feature.m is called. Delete or rename your feature.m.

Opening a mdf file in matlab

I used to use tool to convert those mdf files to .mat, but apparenlty the developer hasn't updated it. It does not work any more.
Is there any other tool with which i can convert to .mat file or directly load and open the .mdf file?
error:
Attempt to reference field of non-structure array.
Error in mdfimport>Load_MDF_File_Callback (line 603)
cd (handles.pathName); % Change to current or last
directory looked at
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in mdfimport (line 87)
gui_mainfcn(gui_State, varargin{:});
Error while evaluating uimenu Callback
For reference: if you have MATLAB R2016b or later, and your MATLAB licence includes the Powertrain Blockset or the Vehicle Network Toolbox, you can use the mdf function to read MDF files.

TMG matlab tool error

I am trying to generate a tf-idf representation of a text file using TMG matlab tool.
This is how I set up my variables:
When I press continue, I get the following error.
Undefined function or variable 'new_sprintf'.
Error in tmg_p
Error in tmg (line 124)
if nargout==8, [varargout{1}, varargout{2}, varargout{3}, varargout{4}, varargout{5}, varargout{6}, varargout{7},
varargout{8}]=tmg_p(varargin{1}, varargin{2}); end
Error in tmg_gui>ContinueButton_Callback (line 456)
[A, dictionary, global_weights, normalization_factors, words_per_doc, titles, files, update_struct]=tmg(filename, OPT);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in tmg_gui (line 27)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>#(hObject,eventdata)tmg_gui('ContinueButton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
And the environment path changes to: log_files
What's causing this and how can I fix it?
I had this problem too: you have to add the path of TMG to MATLAB before using it.
I had this problem, but installing MATLAB 2013a or 2012b and using an earlier verion of tmg solved my problem.

MATLAB newbie: error using sprintf. Function is not defined for 'matlab.graphics.GraphicsPlaceholder' inputs

Today I tried to run a MATLAB m-file that someone gave me. It works fine for him, but I encountered a warning and errors (below). I am using a Mac with OS X Yosemite (10.10.5) and a new version of MATLAB (R2015b). The person who prepared the m-file would have used an older one and Windows.
From a blog at Mathworks and posts online/here, the error seems to be due to a MATLAB update--a change from using numeric values to point towards graphics objects to using objects themselves. I understand this in theory, but don't know how to fix my code (it has been years since I used MATLAB regularly, so I'm pretty lost).
Warning: Text handle output is not supported when a contour handle
argument is supplied and label placement is automatic.
In clabel (line 214)
In control_volume_20150706>plot_xxx (line 733)
In control_volume_20150706 (line 104)
In run (line 96)
Error using sprintf
Function is not defined for
'matlab.graphics.GraphicsPlaceholder' inputs.
Error in control_volume_20150706>plot_xxx (line 734)
sprintf('%10.4f \n',text_handle);
Error in control_volume_20150706 (line 104) plot_xxx (nr,
xwidevec, yhighvec, omegamat, psimat, umat, vmat, ...
Error in run (line 96) evalin('caller', [script ';']);
This is what the code looks like in the vicinity of line 733:
Line 731 contourlevels = omegamat(1, :) ;
Line 732 [C,h] = contour(X,
Y, flipud(omegamat), contourlevels, 'LineWidth', 2 );
Line 733
text_handle = clabel(C,h);
Line 734 sprintf('%10.4f \n',text_handle);
I would be very grateful for any hints about how to deal with this.
If h is a handle which refers to some object, then in R2015a and later this is the object itself, while in previous versions it's a double which points to an object (as you noted in the question). You can use h.double in R2015a and later to get what would previously be h. E.g., pre-R2015a h = figure(999) would set h to 999, a double; with R2015a and later h is an object and h.double is 999.

Error using parallel_function (matlabpool & parfor)

I want to read a large amount of files, process each of them and save the results for each of them in a .mat file. The processing of each file is independent from the others, so I'd like to try using parfor. I have written the following Matlab script file:
load filelist
obj = package.name.SomeObject();
matlabpool local 5
parfor i=1:length(filelist)
result = obj.compute(filelist{i});
[~, name, ~] = fileparts(filelist{i});
save(['~/path/' name], 'result');
end % file loop
matlabpool close
When I try to run it on my computer, a Matlab pool is intialized (connected to 5 workers), but then the following error message occurs:
Error using parallel_function (line 589)
Undefined function or variable "cleaner".
Error in readfiles (line 14)
parfor i=1:length(filelist)
Error in run (line 64)
evalin('caller', [script ';']);
Do you know where the problem could be?
I don't know why (there might be a connection to this issue), but the problem was solved by enclosing the code inside a function and calling that function (instead of calling the script file by run script.m). It also required creating a parsave function (see explanation here).