Noob MATLAB Question - Importing Data

In summary, the problem was that the incoming data was in a format that wavread was not able to process, causing an error. After downloading the codec already linked on this topic, the problem was resolved.
  • #1
GreenPrint
1,196
0

Homework Statement



Search the internet for some fun sound bytes to include in your programs. Two sources are http://www.wavcentral.com and http://www/wavsource.com . Import the sound byte and use it in an appropriate sport in your program. For example, end your program with Elmer Fudd singing "Kill the Wabbit."

Homework Equations





The Attempt at a Solution



So I located a file that I wanted to use, downloaded it the current directory with all my other MATLAB files.

http://www.wavsource.com/snds_2011-07-03_6218469021342645/tv/looney_tunes/kill_wabbit2.wav

but when I input the following command I get an error

y=wavread( 'kill_wabbit2.wav' )
? Error using ==> wavread at 166
Data compression format (Format #85) is not supported.

I was wondering what exactly it is that I'm doing wrong and how to produce the results that the problem was expecting me to because it appears that I did something wrong.
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Do you have audio codec #85? If not: http://www.updatexp.com/audio-codec-tag-85.html
 
Last edited by a moderator:
  • #3
No. After installing it though I still get the same result.

I think I may be having installation issues.
 
  • #4
I get this window to come up but the folder that it installs the files to is apparently empty.
Wait I take that back it's not empty...
 

Attachments

  • Capture.JPG
    Capture.JPG
    36.8 KB · Views: 475
  • #5
This is what it put into the installation file. It would seem to have installed correctly yet I'm still getting the same results when I try to run that commands in MATLAB
 

Attachments

  • Capture.JPG
    Capture.JPG
    49.5 KB · Views: 507
  • #6
I however don't think it's something wrong with my pc just that there's something wrong with MATLAB or that I don't have a certain codec or something. If it's something wrong with my laptop what exactly is causing it not to install correctly and how do I resolve that issue so that way I can get MATLAB to run that command without getting an error message?
 
Last edited by a moderator:
  • #7
Alright well I uninstalled the program from my computer. I tried rerunning it in comparability mode with Windows 95, thought maybe it had a problem installing on Vista or something, but the same results happen. Also this is the window that pops up after I try to close the window that comes up in my third post. Clicking on resume just does nothing but leave me at the window in my third post in this topic so the only thing I can do is click exit which closes the window
 

Attachments

  • Capture.JPG
    Capture.JPG
    13 KB · Views: 441
  • #8
So I'm wondering if that was the correct program?
 
  • #9
Something to consider:

Sometimes audio is taken in two channels, or one channel, or simply puts the recorded data in a different format then what the MATLAB mfile that reads it is expecting. This can obviously, at times, cause problems during the read.

Have you stepped into the actual MATLAB mfile that does the reading? The format of the incoming data could be what is wrong. Another way of testing this would be getting waveform files from a different source and seeing if the same error comes up.

A secondary, indirect solution would be to convert your wav file to a different format, then try to input the data once more. This would shed light on whether or not format is an issue.

I would try these things first before dealing with re-installations and codecs.
 
  • #10
well I tried this file instead
http://www.wav-sounds.com/answering_machine/rappin.wav
and the same thing occured

and no I haven't stepped into the actual MATLAB mfile that does the reading

ok I tried a different format, the only other format that I'm aware that MATLAB can read is .au so I download this file
http://simplythebest.net/sounds/other_formats/Sun_Audio/sound_effects_AU/sound_effect_AU_files/bird_1.au

sense i don't know the command to directly read it I tried importing it
file->Import Data...-> clicked on the file

and the window in the attachments came up

I tried doing the same with both .wav files but some window comes up with the message
uniterpertable data
 

Attachments

  • Capture.JPG
    Capture.JPG
    29.4 KB · Views: 608
Last edited by a moderator:
  • #11
Okay, I actually sat down and tried it. It was definitely a codec problem. Once I downloaded the codec already linked on this topic, it worked for me. But if you can't get that to work for some reason or another here's a way I got around it - it's a bit unsophisticated though.

If you open the file in Microsoft sound recorder and then go "file -> properties -> convert now" you can change the wav file to a PCM format. Or if your particular version of Microsoft Sound Recorder doesn't have this option you can download Switch Sound File Converter and open the wav file and convert it to a wav file, but with the option chosen of "PCM Uncompressed" under encoder options. Your problem is that, while your wav file is the correct type of file, it is compressed in a fashion that wavread is not able to process. This often happens when downloading files from the internet which have their own stipulations on compression. If, say, you were to make this wav file from Matlab and then upload it, this problem would not occur. It's all about the compression options. Either way, converting it thus will avoid your problem. Open it in MATLAB and you should be fine.
 
Last edited:
  • #12
Hi Ecthelion,

Thanks for your help. I'm going to see if I can get it to work. I take it you mean the Switch Sound File Converter? I can't seem to find the recorder. My version of Microsoft Sound Recorder doesn't allow me to open files just record.
 
  • #13
So I just converted it online sense I was having troubles. It seems to work fine but when I input this command
y=wavread('kill_wabbit')
a whole bunch of numbers just shows up...
lets see...
 
  • #14
and my speakers are working fine...
I also tried this just get a whole bunch of numbers>> [data,fs]=wavread('kill_wabbit2.wav')
 
  • #15
Graph the numbers. Does it look like a voice signal? Are the values high enough to produce a sound?

I'm assuming you're trying to play the wavefile - what command are you using? All wavread is doing is importing the data. Type in "doc wavread" and look at the options the article presents in and at the end to play the data.
 
Last edited:
  • #16
thanks =)
 

1. How do I import data into MATLAB?

To import data into MATLAB, you can use the importdata function. This function allows you to import data from various file formats such as .csv, .txt, and .xls. You can also specify the delimiter and header lines in the function to correctly import your data.

2. Can I import data from an external source, such as a website or database?

Yes, you can import data from external sources by using the urlread or webread functions. These functions allow you to retrieve data from a URL or web service and import it into MATLAB.

3. How can I handle missing or corrupted data during the import process?

You can use the NaN (Not a Number) or MissingData options in the importdata function to handle missing or corrupted data. This will replace the missing or corrupted data with NaN values, which can be easily managed in MATLAB.

4. Can I import data into specific variables in MATLAB?

Yes, you can use the assignin function to import data into specific variables in MATLAB. This function allows you to assign imported data to a variable of your choice, making it easier to work with multiple datasets in your MATLAB code.

5. Is it possible to import data from a file with a custom format?

Yes, you can use the textscan function to import data from a file with a custom format. This function allows you to specify the format of your data and can handle a variety of data types such as strings, numbers, and dates.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
8K
  • Programming and Computer Science
Replies
6
Views
1K
Back
Top