error in loading a file in MATLAB - matlab

I want to load a video in yuv extension using the function load.
load foreman_qcif.yuv
But I get this error
??? Error using ==> load
Unknown text on line number 1 of ASCII file C:\Users\Chaine\Downloads\foreman_qcif.yuv
"Øÿ".
Also, I would like to place the values or parameters of that video into a cell array. I found a function "struct2cell" but I think I used incorrectly. How must I manipulate the digital video in frames using matrices for each frame?

load is for loading .mat files (MATLAB data files) or ASCII files, see documentation for more details.
You probably want to use the VideoReader class, but you'll need to convert your file into a supported file format first.

I think there don't exist way to read (or, load) YUV files. Function load exists only for MAT files (.mat).
Check these links:
http://www.mathworks.com/matlabcentral/fileexchange/6318
https://www.mathworks.com/matlabcentral/fileexchange/36417-yuv-files-reading-and-converting

Related

load unix executable file to ascii

I am simply trying to load ascii files with two columns of data (spectral data).
They were saved originally as .asc.
I need to open and edit them using text editor before I can load them into Matlab to erase the headers, but some of them somehow got converted to unix executable foramt with the .asc extension. And others are plain text docs also with the same extension. I have no idea why they got saved with the same extension and with my same manipulation as different kind formats.
When I use the load command in Matlab, the plain text docs load normally as expected but the ones saved as unix executable kinds give me this error:
Error using load Unable to read file filename.asc: No such file or
directory.
How can I either resave them (still with the same extension) or otherwise load them to be read by Matlab as standard two column data matrixes?
Thanks!
If these are truly plain text files, try renaming the file from xxx.asc to xxx.txt. Then, see if you are able to edit them as desired.

Load an image from its absolute path in Matlab also if is not included in working directory

I have the absolute path of an image myabspath
D:\myimages\venus\surface\im0012.jpg
I have tried
im=imread(myabspath);
but doesn't work because seems that imread accept only the name of a file in the current working directory.
I have also tried
f=load(myabspath);
But get an error "Argument must contain a string".
Seems a pretty basilar operation but unfortunately I haven't found the solution.
EDIT
Seems that the problem is caused by the fact myabspathis not a regular String but a cell, I have tried to use
myabspath=cellstr(myabspath)
but I continue to receive the error that tell me that myabspath is not a string, but if I call
display(myabspath)
I see the right path. Any solution?
If you have a cell that contains the String path, you don't need any conversion, is enough access the content of the cell using {index}.
Eg
if you have to get the first element use myabspath{1}
imread is able to read images from absolute paths
It seems strange.
Did you get a specific error message?
Does the image actually exists?
Did you, perhaps, write a "your own" imread function which overrides the "MatLab" one?
According to MatLab (R2012b) help, imread also accepts "full pathname"
imread Read image from graphics file.
A = imread(FILENAME,FMT) reads a grayscale or color image from the file
specified by the string FILENAME. If the file is not in the current
directory, or in a directory on the MATLAB path, specify the full
pathname.
I've replicated your folder structure, I did not add it to the MatLab path, nevertheless and I've been able to read an image with imread by specifying the full pathname.
This is the output I've got:
>> myabspath='D:\myimages\venus\surface\im0012.jpg'
myabspath =
D:\myimages\venus\surface\im0012.jpg
>> im=imread(myabspath);
>> whos
Name Size Bytes Class Attributes
im 421x500x3 631500 uint8
myabspath 1x36 72 char

How to convert a .txt to .cdf ? Needed for Matlab that won't read txt as cdf

I have a txt file that contains data in Common Data Format( CDF ).
Matlab has functions to read this but it does not work. I assume because the extension is .txt and not .cdf.
When I try to read it I get:
??? Error using ==> cdfinfoc
Error issued from CDF library: "NOT_A_CDF_OR_NOT_SUPPORTED: Named CDF is corrupted or
not supported by the current library version."
Error in ==> cdfinfo at 170
tmp = cdfinfoc(filename);
Error in ==> cdfread at 184
info = cdfinfo(filename);
Is there a way to trick Matlab and read it or do I need to transform somehow the txt into a .cdf? If so, how do I do that?
Thank you!
EDIT: The file that I am trying to read is from this link: http://www.ee.washington.edu/research/pstca/pf14/ieee14cdf.txt
This says that the data is in CDF: http://www.ee.washington.edu/research/pstca/pf14/pg_tca14bus.htm
If it's actually a txt file (in that it contains textual data that you can read), then it isn't really in CDF format. You can try makeCDF or some other tool to convert the textual data into a CDF file.
If that doesn't work out for you, you'll need to post more information about the actual format of the file. That text file could contain anything. Maybe provide some example lines?
EDIT
After looking at your file, this is an unrelated format which happens to also be called CDF. You can find a reader for this format here: Read IEEE Common Data Format (CDF) (Power systems, Load Flow)
In both cases I think where it's actually falling over is this call to the library:
fmt = cdflib.getFormat(cdfid);
See: cdflib.getFormat, in particular these lines:
This function corresponds to the CDF library C API routine
CDFgetFormat.
To use this function, you must be familiar with the CDF C interface.
Read the CDF documentation at the CDF Web site.
At any rate it's not due to the file extension alone; I tested this by making a copy of the MATLAB example.cdf, renaming it to example.txt, and calling cdfinfo on both. No errors, returned data is the same except for obvious things like filename/modification date.

issues of saving a large scale matrix to mat file

I was trying to save a matrix into a mat file, but the Matlab returns the following messages:
Warning: Variable 'listmatrix' cannot be saved to a MAT-file whose version is older than 7.3.
To save this variable, use the -v7.3 switch.
Skipping...
What does it mean for "use the -v7.3 switch"?
Should I use
save testresult.mat -v7.3 listmatrix
or sth else?
Hi i thought I’d reply to this thread as I’ve been trying to figure out how to save a large (>2 GB) .mat file in matlab v7 (v7.1.0.183) (R14) and finally found a solution.
If you try to use the save command you will get the following error:
save('test.mat', 'data');
Warning: Variable 'data' cannot be saved to a MAT-file because its
storage requirements exceed 2^31 bytes. This limitation will be
addressed in a future release. Consider storing this variable in HDF5
file format (see HDF5WRITE). Skipping...
The solution is to write a HDF5 file instead:
hdf5write('test.hdf5', '/dataset1', data);
You can then read the data back into matlab using:
hdf5read('test.hdf5', '/dataset1');
A quick google search says yes. Try
save -v7.3 testresult.mat listmatrix
How big is your object? (Do whos listmatrix)
You could potentially save memory by using different data type such as uint8.
http://www.mathworks.ch/matlabcentral/newsreader/view_thread/243327
http://www.mathworks.de/matlabcentral/newsreader/view_thread/307845

How to read a ".wav" file into MATLAB?

I wanted to input a wave file in the MATLAB so that I could process it using filters, when I come to input the wave file called wave.wav, this file is located on my desktop, and then I used
[y, fs, nb] = wavread('wave.wav');
to read the wave file but always gives me an error cannot open file, the only thing I can think of is that the function doesnt know the path of the wave.wav, any help?
And how can I play the file also using MATLAB after read, sound()?
Yes, you are correct on both counts. Use the full path to the file, and use the sound function to play it back. See this reference page for a thorough example. The documentation from the Mathworks is quite comprehensive.
This works:
[y,Fs]=wavread('filename');
sound(y,Fs);
note: the filename could be any audio file. but use a converter from .mp3 to .wav coz filename must be in wav format( few even say that waveread converts the file automatically into .wav file but in my case it did not!! )
:)
Use the full path to the file and you can play the sound using soundsc(y,fs) instead sound