saving an variable into matlab for future use

3 次查看(过去 30 天)
how is it possible to save an array of 1 row and 3 column. first column contain an integer, second column contain a string, third column contain an audio file.
basically i want to assign an audio file and a string to several variables. then when i select on the desired variable, it will display the string and play the audio file.
thanks for helping me out

回答(1 个)

Iain
Iain 2013-7-16
Use cell arrays:
variable{1} = 4;
variable{2} = 'String';
variable{3} = 'D:\filehere\hi.wmv';
variable{4} = yourloadfunction('D:\filehere\hi.wmv'); %replace "yourloadfunction" with a file reading function you know and trust.
Alternatively, use a structure:
My_structure.Integer = 4;
My_structure.String = 'String';
My_structure.filename = 'D:\filehere\hi.wmv';
My_structure.file = yourloadfunction('D:\filehere\hi.wmv');
You can also use arrays of structures:
My_structure(2).Integer = 5;
etc etc.

Community Treasure Hunt

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

Start Hunting!

Translated by