Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

how to create a mat file of a given image with the same file name?

t=imread('a.jpg') is the code. my output mat file should be a.mat what is the code.



2 Answers

Answer by Lisa Wu

Lisa Wu (view profile)

on 10 May 2013
t = imread('a.jpg ');
save('a.mat','t');   % save the varible t to a.mat 
 Usage of function SAVE is :save (FILENAME ,VARIABLES)
 and both filename and varible should be a string , 
 for example ,filename shoule be 'filename.extension ';
 Know more about SAVE ,you can type Help save in command window 

1 Comment

if the file name is a.jpg, then i should get a.mat... if the file name is castrol.jpg, then i should get castrol.mat... file names are random. user can select any image downloaded from google.main objective is to create a mat file automatically with the same file name itself..

Lisa Wu

Lisa Wu (view profile)

Answer by Yao Li

Yao Li (view profile)

on 10 May 2013



to define the name of the mat file

For example, filename='a';



You may also have to create a function to remove the extension of the figure name (.jpg)

1 Comment

ok. is it mandatory to remove the jpg extension? If yes... then how to remove it?

Yao Li

Yao Li (view profile)

Contact us