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

7 vues (au cours des 30 derniers jours)
Sivakumaran Chandrasekaran
t=imread('a.jpg') is the code. my output mat file should be a.mat what is the code.

Réponses (2)

Lisa Wu
Lisa Wu le 10 Mai 2013
Modifié(e) : Walter Roberson le 23 Juil 2023
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
  2 commentaires
Sivakumaran Chandrasekaran
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..
Pooyan Rezaeipour
Pooyan Rezaeipour le 23 Juil 2023
Thank you very much!

Connectez-vous pour commenter.


Yao Li
Yao Li le 10 Mai 2013
try
strcat()
to define the name of the mat file
For example, filename='a';
matfilename=strcat(filename,'.mat');
save(matfilename,'t');
You may also have to create a function to remove the extension of the figure name (.jpg)
  2 commentaires
Sivakumaran Chandrasekaran
ok. is it mandatory to remove the jpg extension? If yes... then how to remove it?
Stephen23
Stephen23 le 23 Juil 2023
"is it mandatory to remove the jpg extension?"
No.
"If yes... then how to remove it?"

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by