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

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

how to get the matfile with a particular name

Asked by Elysi Cochin on 16 Mar 2013

i have 10 matfiles named 1.mat, 2.mat to 10.mat.... In these 10 matfiles i have saved a variable varValue...... Based on a calculation i get a value between 1 and 10..... If i get 3..... i need to load 3.mat..... but i dont know how to load it to get the varValue in 3.mat.....

i as below...

 outputValue = '3';
 pathName = 'DB_Matfiles/';
 dataFilename = [pathName imageName '.mat']
 vars = {'varValue'};
 BW = load(dataFilename, vars{:});

sir this varValue actually contains an binary image.... but when i use imshow(BW),

i cant view it...

but if i do

 load 1.mat
 imshow(varValue);

it works..... sir how get the matfile saved in folder 'DB_Matfiles' and named as 1.mat to 10.mat...

if i get 3....

it should load 3.mat from 'DB_Matfiles' folder...

please do reply sir.....

0 Comments

Elysi Cochin

Tags

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek on 16 Mar 2013
Accepted answer
k=3
filname=sprintf('%d',k)
BW = load(filename)

1 Comment

Elysi Cochin on 16 Mar 2013

thank u sir...

Azzi Abdelmalek

Contact us