Exporting HDF4 data in Matlab [duplicate] - matlab

This question already exists:
Matlab HDF Files [closed]
Closed 8 years ago.
I need a script to export data from Matlab to HDF4 format. The variable which I want to store in hdf4 file has dimensions 3128*242*256 (int 16 type).
Thanks

use following routines:
x = ones (3128, 242, 256) ;
hdf5write ('file path', 'dataset name' , x )
Above code will create hdf5 file and containing a dataset having 3D matrix containing values 1.

Related

save the file with loop index in matlab [duplicate]

This question already has answers here:
How to save each file in a for loop using matlab
(1 answer)
save each data in loop as text file in matlab
(1 answer)
Save images in a loop with variable file names?
(2 answers)
Closed 10 months ago.
I want to save some variables in matlab program like
for i =1:10
x(i)=randn()*5;
save(i,x(i));
end
At every iteration 'i' I want it save the values of x(i), but matlab gives me the error "Error using save Must be a string scalar or character vector." How can I solve this

Read multiple csv files in MATLAB [duplicate]

This question already has answers here:
Loading files in a for loop in matlab
(1 answer)
Loop for loading and saving .mat files
(1 answer)
Load an do operations with a matrix whose name varies within a Matlab loop
(1 answer)
Loading a series of text files at matlab
(2 answers)
Closed 2 years ago.
I would like to read several CSV files in MATLAB.
The names of the files are as follows:
data_00001.csv,
data_00002.csv,
...,
data_00010.csv,
data_00011.csv,
...,
data_00100.csv,
data_00101.csv,
...,
data_01000.csv,
data_01001.csv,
...
I would like to know how I can update the name (i.e., number of zeros in the csv file name) and read these files using "for" loop in MATLAB.
You can use sprintf and readmatrix:
for i = 1: 10000
name = sprintf ('data_%0.5d.csv', i);
mat = readmatrix (name ); % or mat = csvread (name );
% ...
end

Reading an image in MATLAB [duplicate]

This question already has answers here:
How to read images from folders in matlab
(3 answers)
Closed 6 years ago.
I want to load an image in MATLAB :
f=imread('fulldirectory');
m=size(f);
printf('m');
MATLAB shows me this error when I attempt to run it:
"Error using imread (line 349)"
Can anyone help me?
Imread function needs a file format, e.g., jpg.
You can use one of the following MATLAB codes.
f = imread('ngc6543a.jpg');
f = imread('ngc6543a', 'jpg');
Also, just omit the semicolon (;) from your second line of your codes, if you want to know the dimension of the image. MATLAB will display the size of the image.
m=size(f)
MATLAB has some test images such as ngc6543a.jpg and you can try my code in your MATLAB.

How to read multiple images using a loop in MATLAB? [duplicate]

This question already has answers here:
How to read mutliple images in a for loop in MATLAB?
(2 answers)
Closed 6 years ago.
I have a folder with the images that I want to read into MATLAB and perform various built-in functions and matrix operations to those input images.
Could anyone possibly help me figure it out?
assuming your images are .jpg:
files = dir('directory*.jpg');
for i=1:length(files)
images{i} = imread(files(i).name);
end
reads all images in current directory into cell array images
this one reads from directory:
directory = 'path to your directory';
files = dir([directory '/*.jpg']);
for i=1:length(files)
images{i} = imread([directory '/' files(i).name]);
end

Can matlab read an image file stored in *.raw format [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a function in MATLAB that converts a .raw file into a matrix?
I have a image stored in .raw format. I would like to read it with matlab. Is it possible?
If not, what shld i do such that matlab can read .raw format?
There is a SO topic you can check out. Is there a function in MATLAB that converts a .raw file into a matrix? .
Also you can check multibandread.